toast為消息提示框,支持自定義位置、持續時間和樣式。
一,注意事項
方法1 引入整個 Mint UI 組件,並需要再次單獨引入Toast組件
Toast,它並不是一個全局變量,需要先引入 import { Toast } from 'mint-ui'
再使用
Toast('提示信息');
方法2 引入整個 Mint UI 不再單獨引入Toast組件
this.$toast('提示信息');
官方文檔沒寫,但看下源碼的index.js就找得到
Vue.$messagebox = Vue.prototype.$messagebox = MessageBox;
Vue.$toast = Vue.prototype.$toast = Toast;
Vue.$indicator = Vue.prototype.$indicator = Indicator;
(所有引用插件的源碼都在node_modules下面)
二,用法
1.基本用法
Toast('提示信息');
2.多配置用法
let instance =
Toast({
message: '提示',
//
提示內容分
position: 'bottom', //提示框位置 duration: 5000 , //持續時間(毫秒),若為 -1 則不會自動關閉 iconClass: 'icon icon-success' , //icon 圖標的類名 className:'addClass' //Toast 的類名。可以為其添加樣式 });
setTimeout(() => {
instance.close()
}, 2000)