美文网首页
vue中封装时间处理(filter)

vue中封装时间处理(filter)

作者: Grandperhaps | 来源:发表于2020-12-01 22:50 被阅读0次
    Vue.filter('dateFormat', function(originVal) {
      const dt = new Date(originVal)
    
      const y = dt.getFullYear()
      const m = (dt.getMonth() + 1 + '').padStart(2, '0')
      const d = (dt.getDate() + '').padStart(2, '0')
    
      const hh = (dt.getHours() + '').padStart(2, '0')
      const mm = (dt.getMinutes() + '').padStart(2, '0')
      const ss = (dt.getSeconds() + '').padStart(2, '0')
    
      return `${y}-${m}-${d} ${hh}:${mm}:${ss}` // 1970-01-18 20:39:05
    })
    

    相关文章

      网友评论

          本文标题:vue中封装时间处理(filter)

          本文链接:https://www.haomeiwen.com/subject/ygmewktx.html