Skip to content

你好,关于一些重写api的问题 #7

@rosa5500

Description

@rosa5500

起因:app.js引入weconsole之后,报错。定位之后,发现是因为relaunch的传参错误,原始代码传入了url字符串。

// app.js
onShow(options) {
    wx.getStorage({
        key: 'sid',
        success(res) {
            that.setSid(res.data.value);
            that.storeBindings.updateStoreBindings();
        },
        fail(err) {
            wx.nextTick(() => {
                wx.reLaunch(HOME_PATH); // ****************报错行数,HOME_PATH='/page/home/index'
                // 正确的写法  wx.reLaunch({url: HOME_PATH}); 
            });
        }
    });
}

报错控制台
image

Error: MiniProgramError
{"errno":1001,"errMsg":"reLaunch:fail parameter error: parameter.url should be String instead of Undefined;"}
    at Object.errorReport (WAServiceMainContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at Function.thirdErrorReport (WAServiceMainContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at Object.thirdErrorReport (WAServiceMainContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at i (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at Object.cb (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at V._privEmit (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at V.emit (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1
    at n (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)
    at Le (WASubContext.js?t=wechat&s=1719467770338&v=3.3.3:1)(env: macOS,mp,1.06.2405020; lib: 3.3.3)

我的问题是,为什么我不用这个包不会引发这个错误?(同样走入了fail()函数中)。我看readme里面说有重写一些方法(console和api),猜测是这个原因。是重写了console的原因还是重写relaunch的原因?想问下,具体是重写了什么内容?影响范围是什么吗?

感谢~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions