Non-separation project using the front and rear end vue inheritance, Public extraction methods and filters

var vue_fn = {
    filters:{
        formatDate: function (value) {
            if(value==null){
                return "";
            }
            let date = new Date(value);
            let year = date.getFullYear();
            let month = date.getMonth()+1;
            let day = date.getDate();
            month = month < 10 ? "0"+month:month;
            day = day < 10 ? "0"+day:day;
            date = year+'-'+month+'-'+day;
            return date;
        },
        formatDateTime: function (value) {
            if(value==null){
                return "";
            }
            let date = new Date(value);
            let year = date.getFullYear();
            let month = date.getMonth()+1;
            let day = date.getDate();
            let h = date.getHours();
            let mm = date.getMinutes();
            let s = date.getSeconds();
            month = month < 10 ? "0"+month:month;
            day = day < 10 ? "0"+day:day;
            date = year+'-'+month+'-'+day+" "+h+":"+mm+":"+s;
            return date;
        }
    },
    methods: {
        showPhoto: function (title, url) {//显示图片
            var json = {
                "data": [{
                    "alt": title,
                    "src": url, 
                }]
            } 
            layer.photos ({ 
                photos: // json format API documentation see the man page 
                //, anim: 1 // Select 0-6, specifying the type of pop-up image animation, default random 
            }); 
        } 
    } 
}

Child vue

var childvue1 = new Vue({
    extends : vue_fn,
    el: '#settleDetailDev',
    data: {
    } ,
    mounted: function () {
    },
    methods: {}
})

  

 

Guess you like

Origin www.cnblogs.com/mafy/p/11897749.html