想把以前做的一个组件做成插件,用下面代码封装:
import Mylib from './mylib'
const lib = {
install (Vue, o) {
var ele = '.elClassName'
if (ele) {
const Mylib = Vue.extend(Mylib)
const pluginName = new Mylib({propsData: {
a: o.a,
b: o.b
}})
setTimeout(() => {
libName.$mount(ele)
}, 0)
}
}
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(pluginName)
}
其中window.Vue.use(pluginName)肯定是不行的,这里我该怎么写才能把参数a和b传进去?