溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何在微信小程序中實(shí)現(xiàn)確認(rèn)框

發(fā)布時間:2021-06-02 17:32:45 來源:億速云 閱讀:1400 作者:Leah 欄目:web開發(fā)

如何在微信小程序中實(shí)現(xiàn)確認(rèn)框?相信很多沒有經(jīng)驗(yàn)的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。

核心代碼如下:

delType:function(e){

 var typeId = e.currentTarget.dataset['id'];

 console.log("delete:"+typeId)


 wx.showModal({
  title: '提示',
  content: '確認(rèn)要刪除該支出類型?',
  success: function (res) {
   if (res.confirm) {
    console.log('用戶點(diǎn)擊確定')

    wx.request({

     url: getApp().globalData.urlPath + "spendingType/delete",
     method: "POST",
     data: {
      typeId: typeId
     },
     header: {
      "Content-Type": "application/x-www-form-urlencoded"
     },
     success: function (res) {
      console.log(res.data.code);
      if (res.statusCode == 200) {

       //訪問正常
       if (res.data.code == "000000") {
        wx.showToast({
         title: "刪除成功,返回支出類型列表",
         icon: 'success',
         duration: 3000,
         success: function () {

          wx.navigateTo({
           url: '../type/type'
          })
         }
        })

       }
      } else {

       wx.showLoading({
        title: '系統(tǒng)異常',
        fail
       })

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

     }
    })


   } else if (res.cancel) {
    console.log('用戶點(diǎn)擊取消')
   }
  }
 })

}

wxml代碼如下:

<text bindtap='delType' data-id="{{item.typeId}}">刪除</text>

看完上述內(nèi)容,你們掌握如何在微信小程序中實(shí)現(xiàn)確認(rèn)框的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI