当前位置:首页 > Web开发 > 正文

vue 自定义js文件 写方法

2024-03-31 Web开发

//全局函数方法 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);

vue 自定义js文件 写方法

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/42729.html