import Vue from 'vue';
export default ()=>{
Vue.prototype.$alert= (options)=>{
return new Promise((resolve, reject)=>{
let alert = Vue.extend(require('./alert.vue'));
options.callback=resolve
let instance=new alert({
data: options
});
instance.$mount();
console.log(instance)
document.body.appendChild(instance.$el);
})
}
}
在其他vue组件调用 this.$alert() 时失败
Failed to mount component: template or render function not defined
vue-cli构建。。。
是instance.$mount() 挂载失败。。this.$alert()可以调用
生成的东西是这个<!--function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }-->
export default {
}
我记得Vue的插件需要有个install方法吧