封装一个类
在js文件中定义一个类并导出
class mask {
constructor(title = '', icon = "none") {
this.title = title
this.icon = icon
}
// 消息提示框
toast() {
wx.showToast({
title: this.title,
icon: this.icon,
duration: 2000,
mask:true
})
}
}
export {mask}
在要使用的文件中引入
import {mask} from '@/common/common.js'
在使用的地方
new mask('测试').toast()