微信小程序之幾種常見的彈框提示信息


一、模態窗口

wx.showModal

 delete(){
    wx.showModal({
      title: '',
      content: '是否確認刪除',
      success(res) {
        if (res.confirm) {
          console.log('用戶點擊確定')
        } else if (res.cancel) {
          console.log('用戶點擊取消')
        }
      }
    })
  }

二、提示你想提示的信息

提示你想提示的信息

wx.showToast({
  title: '成功',
  icon: 'success',
  duration: 2000
})

注意
wx.showLoading 和 wx.showToast 同時只能顯示一個
wx.showToast 應與 wx.hideToast 配對使用

三、顯示 loading 提示框

wx.showLoading

wx.showLoading({
  title: '加載中',
})

setTimeout(function () {
  wx.hideLoading()
}, 2000)

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


免責聲明!

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



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