1. 程式人生 > >小程式執行報錯:“appLaunch with an already exist webviewId 166”

小程式執行報錯:“appLaunch with an already exist webviewId 166”

錯誤原因:
連續點選會多次跳轉 建議不要用navigator元件,早上剛問過騰訊的人,說以後會優化這個bug。

解決方法:
要避免這個問題可以先在util全域性定義一個方法,然後再頁面內執行跳轉
function buttonClicked(event) {
  var that = this
  that.setData({
    buttonClicked: true
  })
  setTimeout(function () {
    that.setData({
      buttonClicked: false
    })
  }, 500)
}

Page({
  data: {
    buttonClicked: false
  },
  click: function (event) {
    var that = this
    if(!that.buttonClicked){    
        util.buttonClicked(that);
        var id = event.currentTarget.dataset.id;
        wx.navigateTo({
          url: '../detail/detail?id=' + id
        })
    }
  },
})