起因
因为自己做的一个项目用到的是Vuetify,然而它本身不支持全局的消息提示,所以参考了网上的教程之后,自己实现了一个Vue的全局Toast消息插件。npm地址:toast_demo_based_vue
安装
$ npm i toast_demo_based_vue
引入
import toastRegistry from 'toast_demo_based_vue'
Vue.use(toastRegistry)
使用方法
this.$toast({
text: "Your text",
type: "type",
duration: time
});
部分API
参数 | 说明 | 值 |
---|---|---|
type | 提示类型 | success/wraning/danger/info |
text | 文本 | null |
duration | 持续时长 | 2000毫秒 |
部分界面
danger
success