wx.reLaunch无法通过try{} catch (e) {}并处理错误?
发布于 6 年前 作者 tjia 1922 次浏览 来自 问答

用户在setTimeout跳转时隐藏微信切换到其他app,会无法跳转,但也无法通过try{} catch (e) {}进行处理

try{

    //授权后跳转到之前访问的分享转发页面

    if (self.data.goto == ‘true’) {

        var url = self.data.shareGotoUrl;

        if (url.indexOf(“index/index”) < 0) {

            setTimeout(function () {

                wx.reLaunch({

                    url: url

                });

            }, 1690);

        return;

        }

    }

    

    //跳转到精选首页

    wx.reLaunch({

        url: ‘…/jingxuan/index’

    });

} catch (e) {

    console.log(“launch Err!”);

}

1 回复

try-catch 是无法 catch 住异步函数里的异常呀

回到顶部