vue-book icon indicating copy to clipboard operation
vue-book copied to clipboard

第二章 时间格式化处理过滤规则 filters 代码有误

Open rencoo opened this issue 7 years ago • 0 comments

原代码 filters : { formatDate: function(value){// 这里的value就是需要过滤的数据 var date = new Date(value), year = date.getFullYear(), month = padDate(date.getMonth() + 1), day = padDate(date.getDate()), hours = padDate(date.getHours()), minutes = padDate(date.getMinutes()), seconds = padDate(date.getSeconds()); //将整理好的数据返回出去 return year+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds; } }, 可以直接用 date filters : { formatDate: function(date){// date是我们现成的数据,直接过滤就好了 var year = date.getFullYear(), month = padDate(date.getMonth() + 1), day = padDate(date.getDate()), hours = padDate(date.getHours()), minutes = padDate(date.getMinutes()), seconds = padDate(date.getSeconds()); //将整理好的数据返回出去 return year+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds; } },

rencoo avatar Aug 26 '18 10:08 rencoo