小程序自帶彈出框類型


wx.showToast(Object object)

顯示消息提示框  

wx.showToast({
  title: '成功',
  icon: 'success',//當icon:'none'時,沒有圖標 只有文字
  duration: 2000
})

wx.showModal(Object object)

顯示模態對話框

wx.showModal({
  title: '提示',
  content: '這是一個模態彈窗',
  success(res) {
    if (res.confirm) {
      console.log('用戶點擊確定')
    } else if (res.cancel) {
      console.log('用戶點擊取消')
    }
  }
})

wx.showLoading(Object object)

顯示 loading 提示框。需主動調用 wx.hideLoading 才能關閉提示框

workSite: function () {
    var that = this;
    var parma = {
      id: that.data.id,
      p: that.data.p
    }
    wx.showLoading({ title: '加載中', })
    wx.request({
      url: app.globalData.url + "/*******",
      data: parma,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默認值
      },
      method: 'POST',
      success: function (res) {
        console.log(res.data.data)
        if (res.data.code == 1) {
          that.setData({
            listLength: res.data.data.length,
            workSite: res.data.data,
          })
        }
        wx.hideLoading();
      },
    })
  },

wx.showActionSheet(Object object)

顯示操作菜單

wx.showActionSheet({
  itemList: ['A', 'B', 'C'],
  success(res) {
    console.log(res.tapIndex)
  },
  fail(res) {
    console.log(res.errMsg)
  }
})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM