两种方式使用:

一、全局注册

1.在main.js中引入

//引入

import { MessageBox } from 'mint-ui';

 
//全局使用,挂载到原型上

Vue.prototype.$messagebox = MessageBox   

 

2.在xxx.vue使用

//alert

this.$messagebox.alert("操作成功").then(action => {
 
});
 
//confirm
 
this.$messagebox.confirm("确定执行此操作?").then(action => {
 
});
 
//prompt
 
this.$messagebox.prompt("请输入你的姓名").then(({ value, action }) => {
 
});
 
二、局部使用
 
1.在xxx.vue文件的script标签中引入
 
import { MessageBox } from 'mint-ui';
 
2.使用
 
//alert
 
MessageBox.alert("确定执行此操作?").then(action => {
 
});
 
//confirm
 
MessageBox.confirm("确定执行此操作?").then(action => {
 
});
 
//prompt
 
MessageBox.prompt("确定执行此操作?").then(({ value, action }) => {
 
});
 

 附加:(toast | indicator | messagebox)三者使用方式一样

Vue.$messagebox = Vue.prototype.$messagebox = MessageBox;

Vue.$toast = Vue.prototype.$toast = Toast;

Vue.$indicator = Vue.prototype.$indicator = Indicator;


 

相关文章:

  • 2021-12-26
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2021-12-26
猜你喜欢
  • 2021-06-14
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
相关资源
相似解决方案