首页 > 其他 > 详细

vue的filters时间过滤器

时间:2019-08-02 13:40:39      阅读:151      评论:0      收藏:0      [点我收藏+]
  filters: {
    formatTime: function(value) {
      let time = new Date(value * 1000);
      let year = time.getFullYear();
      let month = time.getMonth() + 1;
      if (month < 10) {
        month = "0" + month;
      }
      let day = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();
      let hour = time.getHours() < 10 ? "0" + time.getHours() : time.getHours();
      let minute =
        time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes();
      let second =
        time.getSeconds() < 10 ? "0" + time.getSeconds() : time.getSeconds();
      return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    }
  },

  直接使用{{**|formatTime}}

vue的filters时间过滤器

原文:https://www.cnblogs.com/Glant/p/11287885.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!