首先需要在前端框架的package.json引入moment-timezone
然后需要在index.js文件里面導入moment-timezone
然后在使用的Vue文件里面導入moment-timezone
在Vue文件中,如果在HTML代碼中使用,則需要在return里面定義moment
如果只是在js里面用,就直接用就行了。
let currDate = moment("2020-08-14"); console.log(currDate ); this.dateRange.push(currDate.startOf("month").valueOf());//獲取該月份第一天的時間戳 this.dateRange.push(currDate.endOf("month").valueOf());//獲取該月份最后一天的時間戳 console.log(this.dateRange);
參考momentjs中文官網:http://momentjs.cn/docs/#/manipulating/start-of/
參考鏈接2:http://www.fly63.com/article/detial/5943