Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h5.router.basename 设置后,跳转页面not-found #15296

Closed
baoxiaowang opened this issue Mar 4, 2024 · 2 comments · Fixed by #15361
Closed

h5.router.basename 设置后,跳转页面not-found #15296

baoxiaowang opened this issue Mar 4, 2024 · 2 comments · Fixed by #15361
Assignees
Labels
A-router Area - H5 路由相关 T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@baoxiaowang
Copy link

相关平台

H5

复现仓库

https://github.com/baoxiaowang/taro-case.git
浏览器版本: Chrome 122.0.6261.94
使用框架: Vue 3

复现步骤

配置config下的 h5.router.basename 后 所有的taro 跳转都会失效
观察源码(webpack://myApp/node_modules/@tarojs/router/dist/api.js?aed4)中对跳转路径做了拼接后和app.config.ts 中的pages选项做了incldues 比对,如果不在就会抛出页面没找到的错误

期望结果

期望配置basename = '/h5'
且配置pages:[
'pages/home/index',
'pages/test/index',
]时
Taro.navnavigateTo({
url:'pages/test/index'
})
能够正常跳转

实际结果

navigateTo:fail page h5/pages/test/index is not found

环境信息

👽 Taro v3.6.24


  Taro CLI 3.6.24 environment info:
    System:
      OS: macOS 13.4
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
      Yarn: 1.22.21 - ~/.nvm/versions/node/v18.17.1/bin/yarn
      npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.24 => 3.6.24 
      @tarojs/components: 3.6.24 => 3.6.24 
      @tarojs/helper: 3.6.24 => 3.6.24 
      @tarojs/plugin-framework-vue3: 3.6.24 => 3.6.24 
      @tarojs/plugin-html: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-alipay: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-h5: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-jd: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-qq: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-swan: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-tt: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-weapp: 3.6.24 => 3.6.24 
      @tarojs/runtime: 3.6.24 => 3.6.24 
      @tarojs/shared: 3.6.24 => 3.6.24 
      @tarojs/taro: 3.6.24 => 3.6.24 
      @tarojs/taro-loader: 3.6.24 => 3.6.24 
      @tarojs/webpack5-runner: 3.6.24 => 3.6.24 
      babel-preset-taro: 3.6.24 => 3.6.24 
      eslint-config-taro: 3.6.24 => 3.6.24 

补充信息

taro 3.6.24 bug

@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Mar 4, 2024
@ZEJIA-LIU ZEJIA-LIU self-assigned this Mar 4, 2024
@ZEJIA-LIU ZEJIA-LIU added A-router Area - H5 路由相关 and removed F-vue3 Framework - Vue 3 labels Mar 4, 2024
@HUA616436641
Copy link

react也出现了

ZEJIA-LIU added a commit that referenced this issue Mar 8, 2024
* fix(#15296): 修复路由有 basename 的情况下navigate 报错

* feat: 替换basename的插入方式,和4.x保持统一

---------

Co-authored-by: liuzejia <liuzejia@SZMAC-FV0MR4G7.local>
@HUA616436641
Copy link

HUA616436641 commented Mar 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-router Area - H5 路由相关 T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants