小程序封装提示弹窗showToast

 最好放到app.js中,作为公共函数

  //title(标题),
  //icon(图标),  success,loading,none
  //duration(延时) 0为不关闭, 毫秒数
  //options(其它参数),

  toast(title, icon = 'none', duration, options) {
    wx.showToast({
      title: title || '',
      icon: icon,
      image: (options && options.image) || '',
      duration: duration || 1500,
      mask: (options && options.mask) || true,
    });
  }
发布了149 篇原创文章 · 获赞 51 · 访问量 23万+

猜你喜欢

转载自blog.csdn.net/caoyan0829/article/details/94399495