Toast
简短的消息提示框,支持自定义位置、持续时间和样式。Demo
引入
import { Toast } from 'vue-pmui';
// 全局Api
Vue.prototype.$toast = Toast;
例子
普通调用
Toast('提示信息');
// or
this.$toast('提示信息');
使用自带的状态icon
Toast.info('info', duration);
Toast.error('error');
Toast.warning('warning');
Toast.success('success');
loading
const instance = this.$loading();
// 等价于 Toast.loading();
setTimeout(() => {
// 手动关闭loading
instance.close();
}, 3000);
自定义
Toast.info({
type: '',
message: '提示信息',
icon: '',
mask: false,
duration: 2000
});
Props
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
message | 显示的文本 | String | ||
type | Toast类型 | String | info/error/warning/success/loading | |
icon | 图标样式类名,覆盖type自带的图标 | String | ||
mask | 是否显示遮罩层 | Boolean | false | |
duration | Toast显示时间 | Number | 2000 |