micro-zoe / micro-app

A simple, efficient and powerful micro front-end framework. 一款简约、高效、功能强大的微前端框架
https://micro-zoe.github.io/micro-app/
MIT License
5.59k stars 565 forks source link

路由问题-基座history 子应用-hash 刷新或者回车浏览器 丢失#之前的子应用路径 #152

Closed eric1202 closed 2 years ago

eric1202 commented 2 years ago

问题描述

问题的具体描述

刷新或者浏览器输入丢失路径

目标 http://localhost:8013/appname/#/order 刷新或者回车 http://localhost:8013/#/order 再刷新或者回车 http://localhost:8013/dashboard#/order 再刷新或者回车 http://localhost:8013/dashboard#/order

期望是一直都是目标url http://localhost:8013/appname/#/order

复现步骤

  1. 按照教程设置的

基座应用是history路由,子应用是hash路由,我们要跳转基座应用的my-app页面,页面中嵌入子应用,我们要展现子应用的page1页面。

那么浏览器地址应该为:域名/my-page#/page1,我们在基座中跳转my-app页面的参数为:router.push('/my-page#/page1')

此时基座应用会匹配到/my-page路径并渲染my-app页面,子应用匹配到#/page1并渲染page1页面。

  1. 通过侧边菜单点击是没有问题的,浏览器输入就会有

    环境信息

bailicangdu commented 2 years ago

子应用设置 router.base 为dashboard 试一下呢

eric1202 commented 2 years ago

不行哦 // vue-router在hash模式下不支持base,可以用一个根页面进行包裹 base: window.__MICRO_APP_BASE_ROUTE__ || '/',

eric1202 commented 2 years ago

目前是通过监听路有变化 next({ path: '/' + currentRouter.name + currentRouter.fullPath }) 来解决的 有点不太好

github-actions[bot] commented 2 years ago

Since the issue was labeled with inactive, but no response in 7 days. This issue will be close. If you have any questions, you can comment and reply. 由于该 issue 被标记为不活跃,且 7 天未收到回应。现关闭 issue,若有任何问题,可评论回复。