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

Hash 为true,并同时配置 base 后 hash路径问题 #2743

Closed
mizi-lin opened this issue Jul 2, 2019 · 10 comments
Closed

Hash 为true,并同时配置 base 后 hash路径问题 #2743

mizi-lin opened this issue Jul 2, 2019 · 10 comments

Comments

@mizi-lin
Copy link
Contributor

mizi-lin commented Jul 2, 2019

这其实是 #2597 的后续问题

umi_v2.8.8

场景
.umirc.ts

hash: true,
history: 'hash',
base: '/sub',

启动项目 访问route (NavLink, Link) 后地址为
http://localhost:8001/sub#/sub/base-error

但我所期望的是 (或 2.6 之前版本为)
http://localhost:8001/sub#/base-error

dev 模式下 使用 http://localhost:8001/sub/#/base-error 访问
控制台警告信息

image


可复现资源地址:

git@github.com:mizi-lin/umi-issues.git

@Renderz
Copy link

Renderz commented Jul 12, 2019

原来是版本问题么... 我以为用了base就不能用hash history. 现在用回browserHistory 同时改了nginx的匹配逻辑...

@ycjcl868
Copy link
Contributor

base 去掉就行了

@ycjcl868
Copy link
Contributor

any question?

@mizi-lin mizi-lin changed the title Hash 为true,并同时配饰 base 后 hash路径问题 Hash 为true,并同时配置 base 后 hash路径问题 Jul 17, 2019
@Renderz
Copy link

Renderz commented Jul 18, 2019

base 去掉就行了

功能就是需要base啊... 去掉是什么情况...

@sorrycc
Copy link
Member

sorrycc commented Jul 18, 2019

base 带 / 后缀,我试过这样配没问题,

export default {
  history: 'hash',
  base: '/foo/'
};

@mizi-lin
Copy link
Contributor Author

@sorrycc

使用新配置
问题依旧存在

umi version: 2.8.16

image

@sorrycc
Copy link
Member

sorrycc commented Aug 4, 2019

base 你理解错了,base 是路由的 base,你设了 /sub/ 如果是 hash,那 /#sub/ 是期望的结果。

@sorrycc sorrycc closed this as completed Aug 4, 2019
@mizi-lin
Copy link
Contributor Author

mizi-lin commented Sep 1, 2019

@sorrycc

那混乱了,
在 umi version: 2.8.16 的结果是 /sub/#sub/
而不是你所说的期望值 /#sub/

而 umi_v2.8.8 与你所说更不一致
其表现为 /sub#/

所以这边略显混乱

  • 按你所说 base 是路由的base 那么 就不应该把二级目录也设置为 base 的值 sub/#sub 而应该只是 '/#sub/'

  • 若跟旧版本一样那 base指向的是 二级目录 'sub/#/'
    image

@mizi-lin
Copy link
Contributor Author

mizi-lin commented Sep 1, 2019

@Renderz

你能改配置算好的·
我都不敢动
功能还好
URL 地址不敢改变~
一些客户因为其自身原因,配置后,就不能改变URL地址

现在我因为这么一点点小功能,不能升级UMI也蛮搞笑的··

@everything8
Copy link

怎么解决的?遇到了同样的问题

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

No branches or pull requests

5 participants