Hello!

程序员给自己留条后路

亲爱的朋友

专业挖坑

vue 自定义js文件 写方法

//全局函数方法
exports.install = function(Vue, options) {
    Vue.prototype.$popup = function(msg, time) { 
         //msg 为内容
         //time 弹窗显示时间
          time = isNaN(time) ? 3000 : time;
        var m = document.createElement('div');
        m.className="popupall"
        m.innerHTML = msg;
        document.body.appendChild(m);
        setTimeout(function () {
            var d = 0.5;
            m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
            m.style.opacity = '0';
            setTimeout(function () {
                document.body.removeChild(m)
            }, d * 1000);
        }, time);
      
    };
};

单页调用

that.$popup("发表内容",3000)

main.js文件引用

import com from './public/js/com'
Vue.use(com);

 

posted @ 2019-11-26 12:00  湾子大郊亭  阅读(882)  评论(0编辑  收藏  举报