vue install 组件

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

  

posted @ 2019-12-08 22:18  AlanTao  阅读(2413)  评论(0编辑  收藏  举报