Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

isUrl的判断和 HashRouter 不兼容,导致菜单渲染错误 #40

Closed
dr2009 opened this issue Jul 1, 2019 · 2 comments
Closed

isUrl的判断和 HashRouter 不兼容,导致菜单渲染错误 #40

dr2009 opened this issue Jul 1, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@dr2009
Copy link
Contributor

dr2009 commented Jul 1, 2019

4.5.8版本

export function isUrl(path: string): boolean {
  return reg.test(path) || path.indexOf('/') === 0;
}

认为 /开头的也是外部地址.使用 a 链接,
那么 /demo/a的hashrouter 的地址是 /#/demo/a, 直接a 链接跳转就是错误地址.

自定义的话,defaultDom始终包含 a 链接,和 Link嵌套有问题

menuItemRender={(menuItemProps, defaultDom) => (
        <Link to={menuItemProps.path}>{defaultDom}</Link>
 )}
@chenshuai2144 chenshuai2144 added the bug Something isn't working label Jul 1, 2019
@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Jul 1, 2019

很奇怪为什么 加了个这个 path.indexOf('/') === 0;

@chenshuai2144
Copy link
Collaborator

重新安装一下依赖即可修复。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants