过滤器filters对时间格式的处理

在表格中,我们经常会对时间格式进行处理;
这个时候,我们就可以使用过滤器了。
过滤器是不会,改变原始值

{{  mess | dotime }}
{{  mess | do2time }}
mess: "2020-01-01 12:12:12",

substring(包含起始位下标,不包含结束位下标)

filters:{
    dotime(mess){
        // 显示年月
        if(mess&&mess.length>10){
              return  mess.substring(5,10)
        }
     },

     // 显示小时 分钟
     do2time(mess){
       if(mess&&mess.length>10){
            return   mess.substring(11,16)
        }
     }
},
posted @ 2020-11-26 18:52  南风晚来晚相识  阅读(227)  评论(0编辑  收藏  举报