一个在学习vue的小白,各种折腾,最近页面需要用到toast,故查了部分资料。
使用toast有两个方式,
一个是使用第三方插件(这个网上很多,大家可以自行搜索,上个链接供大家参考https://www.npmjs.com/package/vue2-toast);
另一个方式是自定义一个toast,效果见下图:
文件目录:
index.js文件代码:
import Vue from 'vue'
import toast from './toast.vue'
// 创建组件构造器
const toastHonor = Vue.extend(toast);
export default function ({text="要显示的内容",time=2000,type=undefined}={}) {
return new Promise((reslove, rej