全局过滤器

<script>
    //1.0 定义一个名称为datafmt的全局过滤器
    Vue.filter('datefmt',function (input) {
        var res = '';
        var year = input.getFullYear();
        var month = input.getMonth() + 1;
        var day = input.getDate();
        res = year + '-' + month + '-' + day;
        return res;
    });
    new Vue({
        el: '#app',
        data:{
            time:new Date()
        }
    });
    new Vue({
        el: '#app1',
        data:{
            time:new Date()
        }
    });
</script>

猜你喜欢

转载自blog.csdn.net/weixin_42124866/article/details/81086876