//全局函数方法 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);
原文地址:https://www.cnblogs.com/chen527/p/11934552.html
时间: 2024-10-29 03:12:47