class类封装组件

143 阅读1分钟

定义

class result{

	constructor(title,icon='none') {
	    this.title = title
            this.icon = icon
	}
        
        // 消息提示框
	toast(){
		wx.showToast({
		  title:this.title,
		  icon:this.icon,
		  mask:true,
		  duration: 800
		})
	}
	
}

export {result}

使用

import {result} from '@/Acc-config/public.js'
new result('出错了!').toast()