Moment.js 获取日期时间

1.安装

npm install moment

2.main.js 引入

// 引入moment
import moment from "moment";
Vue.prototype.$moment = moment;

3.使用示例

data() {
    return {
      /* 格式:年-月-日 时-分-秒 */
      nowTime: this.$moment().format("YYYY-MM-DD HH:mm:ss"), 
    };
  },


// 打印试一下
created(){
   console.log(this.nowTime, "nowTime"); //这个就是了
}

猜你喜欢

转载自blog.csdn.net/weixin_52630329/article/details/129503320
今日推荐