自己封装一个vue消息推送组件





Mydialog.js

import MyDialog from '../MyDialog.vue'

const MyDialogs={
  install(Vue){
    Vue.component('MyDialog',MyDialog)
  }
}


//global 情况下 自动安装
if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(MyDialogs)
}
// 导出模块
export default MyDialogs

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import MyDialog from './components/js/MyDialog.js'

Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(MyDialog)

// Vue.use(MyDialog)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: ''
})

hello.vue


 

你可能感兴趣的:(自己封装一个vue消息推送组件)