本文共 375 字,大约阅读时间需要 1 分钟。
安装并使用 Moment.js 文档
安装 Moment.js 库款实用工具
在你的项目根目录下,运行以下命令安装:
npm install moment --save
全局注册 Moment.js
在你的 main.js
文件中,继续进行如下操作:
import moment from 'moment';Vue.prototype.moment = moment;
在组件中直接使用
在需要使用 Moment.js 的页面,直接调用方法:
let a = this.moment(this.MonthData).format("YYYY-MM-DD HH:mm:ss");console.log(a);
综上,通过上述步骤,您可以轻松地在 Vue.js 项目中开始使用 Moment.js 来格式化时间。这么一来,您就可以方便地处理日期和时间了!
转载地址:http://obwhz.baihongyu.com/