微信小程序防止页面重复跳转

data:{link:true}

跳转事件

notifications: function () {

        var that = this;

       link('../notice/notice', that);

},

跳转方法

 

function link(url, that) {
    if (that.data.link == true) {
        that.setData({
            link: false 
        },function(){
            wx.navigateTo({
                url: url,
                complete: function () {
                    that.setData({
                        link: true
                    })
                }
            })
        })
       
    } else {
        return;
    }
}

 

调用navigateTo方法结束事件后要重新setData

 that.setData({
    link: true
 })

 

 

阅读更多
换一批

没有更多推荐了,返回首页