Vue对日期进行格式化操作


 padDate = (value) => {
            return value < 10 ? '0' + value : value;
        }
        var vue = new Vue({
            el: ".ui-container",
            data: { list: [] },
            filters: {
                formatDate: function (value) {  //这里的 value 就是需要过滤的数据
                    var date = new Date(value);
                    var year = date.getFullYear();
                    var month = padDate(date.getMonth() + 1);
                    var day = padDate(date.getDate());
                    return year + '-' + month + '-' + day;
                }
            }
        });

使用:

{{item.CreateTime|formatDate}}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM