安装moment.js插件:npm install moment --save

然后需要在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