Vue定义全局时间过滤器

Vue定义全局时间过滤器

如图所示 (根据自己需要 采取时间)

![![在这里插入图片描述](https://img-blog.csdnimg.cn/8a69347ef24f423bad91e4e62869cf4e.png](https://img-blog.csdnimg.cn/a09df8aa5bfe4e8cac97c503355b7b5d.png

main.js中引用

// 全局的时间过滤器
Vue.filter('dateFormat',function(originVal){
   
    
    
  // 提到需要过滤的日期
  const date = new Date(originVal)
  // 获取年份
  const Y = date.getFullYear

猜你喜欢

转载自blog.csdn.net/sinat_52319736/article/details/127728256