mint-ui
mint-ui copied to clipboard
Mint-ui 全局引用后使用MessageBox提示MessageBox is not a function
Mint-ui 全局引用后使用MessageBox提示MessageBox is not a function
我的代码
methods: {
about: function () {
this.MessageBox('提示', '操作成功')
}
}
提示错误:
Uncaught TypeError: this.MessageBox is not a function
最后发现在main.js中需要添加以下内容才能正常显示
const MsgBox = MintUI.MessageBox
Vue.prototype.$msgbox = MsgBox
Vue.prototype.$alert = MsgBox.alert
Vue.prototype.$confirm = MsgBox.confirm
Vue.prototype.$prompt = MsgBox.prompt
代码改成:
methods: {
about: function () {
this.$msgbox('提示', '操作成功')
}
}
你这样是在Vue的原型上添加了这几个方法, 全局注册仅限components,你这几个方法仍然需要在组件中import 后才能使用
好吧 谢谢你