mint-ui icon indicating copy to clipboard operation
mint-ui copied to clipboard

Mint-ui 全局引用后使用MessageBox提示MessageBox is not a function

Open leochen-g opened this issue 9 years ago • 2 comments

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('提示', '操作成功') } }

leochen-g avatar Jul 11 '17 06:07 leochen-g

你这样是在Vue的原型上添加了这几个方法, 全局注册仅限components,你这几个方法仍然需要在组件中import 后才能使用

confirmTing avatar Jul 12 '17 12:07 confirmTing

好吧 谢谢你

leochen-g avatar Jul 14 '17 02:07 leochen-g