import share from ‘./index.vue‘
export default {
install: (Vue) => {
Vue.prototype.$share = (options) => {
// 1.创建构造器,定义好提示信息的模板
const instance = Vue.extend(share);
// 2.创建实例,挂载到文档以后的地方
let currentShare = new instance();
// 3.添加到DOM
document.body.appendChild(currentShare.$mount().$el);
// 4.设置属性
setTimeout(() => (currentShare.show = true), 0);
// 5.自定义覆盖属性
Object.assign(currentShare, options);
}
}
}
原文:https://www.cnblogs.com/alantao/p/12008290.html