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); } } }