showToast/showModal常见用法

2018-08-08  本文已影响18人  理子
  1. 提示并自动返回上一层
wx.showToast({
                title: '申请成功',
                icon: '',
                image: '',
                duration: 1500,
                mask: true,
                success: function(res) {
                  setTimeout(function() {
                    wx.navigateBack()
                  }, 1500)
                },
              })
  1. 服务器 wx.request 请求失败时的提示,有确定取消按钮
wx.showModal({
          title: '连接错误',
          content: '服务器返回:' + res.errMsg,
          showCancel: true,
          cancelText: '关闭',
          confirmText: '重试',
          success: function (res) {
            if (res.confirm) {
              // console.log('用户点击重试')
              that.onShow();
            } else if (res.cancel) {
              // console.log('用户点击关闭')
            }
          }
        })
  1. 服务器 wx.request 请求失败时的提示,有确定按钮,无取消按钮
wx.showModal({
                  title: '提交失败',
                  content: '服务器繁忙/请检查你的网络',
                  showCancel: false,
                })
上一篇下一篇

猜你喜欢

热点阅读