-1
我有一個對象profileObj.details [0]。時間,其等於「10 4pm至10pm」 我想這個字符串分割成10AM和4PM。拆分在AngularJs字符串2
請幫忙解決這個問題。 在此先感謝
我有一個對象profileObj.details [0]。時間,其等於「10 4pm至10pm」 我想這個字符串分割成10AM和4PM。拆分在AngularJs字符串2
請幫忙解決這個問題。 在此先感謝
您可以array destructuring
一起使用.split
:
const [first, second] = "10AM-4PM".split('-');
console.log(first); // 10am
console.log(second); // 4pm
所以使用字符串函數'.split( ' - ')' – Jecoms