vue.js过滤时间格式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lp15203883326/article/details/83343694
  <td>{{item.testStartDate | formatDate}}</td>
  <td>{{item.testEndDate | formatDate}}</td>

vue:


    var padDate=function(va){
        va=va<10?'0'+va:va;
        return va
     }
 filters: {
                /* 时间过滤器 */
                formatDate:function (val) {
                    var value=new Date(val);
                    var year=value.getFullYear();
                    var month=padDate(value.getMonth()+1);
                    var day=padDate(value.getDate());
                    return year+'-'+month+'-'+day;

                }

            },

猜你喜欢

转载自blog.csdn.net/lp15203883326/article/details/83343694