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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM