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

浏览器点击返回时地址出现错误 #1234

Closed
lilu0826 opened this issue May 28, 2024 · 4 comments
Closed

浏览器点击返回时地址出现错误 #1234

lilu0826 opened this issue May 28, 2024 · 4 comments
Labels
fixed Issue fixed router

Comments

@lilu0826
Copy link

问题描述

路由模式用的native,子应用跳转到某个地址后,点击浏览器刷新后,再跳转到其他页面,再点击浏览器返回后浏览器地址栏出现错误

复现步骤

  1. demo地址: https://github.com/lilu0826/micro-app-bug
    2.下载demo,都是vite+vue3项目,同时运行main-app和sub-app
    3.打开http://localhost:3000/sub-app/about
    image

3.点击【子应用主页】
image

4.再点击浏览器返回按钮,浏览器地址会变成:http://localhost:3000/sub-app/sub-app/about
image
5.子应用渲染错误

上传截图

1.主应用的配置:
image
image
2.子应用就是正常的一个子应用,router接收了window.MICRO_APP_BASE_ROUTE
image

复现仓库

https://github.com/lilu0826/micro-app-bug

环境信息

  • micro-app版本:^1.0.0-rc.5
  • 主应用前端框架&版本:vite+vue3+vue-router4
  • 子应用前端框架&版本:vite+vue3+vue-router4
  • 构建工具&版本:[email protected]
@lilu0826
Copy link
Author

image

研究看了下,应该是子应用的history.state.current 被错误的拼接上了baseroute前缀,和主应用__MICRO_APP_STATE__["my-app"].state.current记录的不一致导致的,主应用记录的是对的,不带前缀。希望官网可以解决这个问题吧。

@lilu0826
Copy link
Author

现在临时的解决方法,在子应用router.beforeEach钩子替换一下history.state.current中的baseroute前缀
router.beforeEach(async (to, from) => { if (from === START_LOCATION && window.__MICRO_APP_ENVIRONMENT__) { window.history.state.current = window.history.state.current.replace(window.__MICRO_APP_BASE_ROUTE__, '/') } })

@bailicangdu bailicangdu added Working on it Working on this issue router labels May 30, 2024
@bailicangdu
Copy link
Member

问题会在近期修复,感谢反馈

@bailicangdu bailicangdu added fixed Issue fixed and removed Working on it Working on this issue labels Jul 29, 2024
Copy link

Hello @lilu0826. The issue you reported has been fixed. This issue will be closed. Thank you for your feedback.
您好 @lilu0826,您反馈的问题已修复,该 issue 将要被关闭,感谢反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Issue fixed router
Projects
None yet
Development

No branches or pull requests

2 participants