新建一个js文件 或者在 main.js里写
import Vue from 'vue'
//引入刚才写的弹框组件
import seeInfoView from '@/components/px/com/seeInfo.vue';
// 返回一个“扩展实例构造器”
let seeInfoConstructor = Vue.extend(seeInfoView);
//导出方法
export const seeInfo = (data) => {
let dom = new seeInfoConstructor({
el: document.createElement('div')
})
document.body.appendChild(dom.$el);
//start为组件内部的方法
dom.start(data)
}
// 挂载到 Vue.prototype
Vue.prototype.$seeInfo = seeInfo
页面使用
this.$seeInfo([传入组件的参数])