uni-app 关于页面路径的问题

uni-app 关于页面路径的问题

示例代码:

1

操作步骤:

如描述这样修改地址

预期结果:

能直接拿到search

实际结果:

不能拿到search

bug描述:

如果页面的路径是http://localhost:5173/yyyNewWeChat/#/?code= 那就可以在onLoad里面拿到e.code;

如果页面的路径是http://localhost:5173/yyyNewWeChat/?code=#/那就在onLoad里面无法拿到e.code;

必须自己

if (!e.code && !e.openId && /\?code=|state=/.test(location.href)) {  
    const url = new URL(location.href)  
    e.code = url.searchParams.get('code')  
    history.replaceState(null, '', url.href.replace(url.search, ''))  
}

这样才可以,官方能否实现啊。由于微信获取code的回调地址是第二种路径就会导致需要自己解析路径。希望官方能优化一下下


更多关于uni-app 关于页面路径的问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

回到顶部