vue/iview使用moment.js

方法一

main.js引入moment
获取当前时间

  this.time = this.$moment()._d; // 当前时间
  this.time0 =this.$moment().subtract(1, 'hours')._d //当前时间的前一小时

打印this.$moment

方法二

当前页面引入Moment

  this.time = Moment().toDate(); // 当前时间
  this.time0 = Moment().subtract(1, 'hours').toDate() //当前时间的前一小时

显示时,用iview中datepicker 的format

<DatePicker :value="time" format="yyyy-MM-dd HH:mm:ss " type="daterange" placement="bottom-end" placeholder="Select date" style="width: 200px"></DatePicker>

posted @ 2019-02-14 13:46  gggggggxin  阅读(1143)  评论(0)    收藏  举报