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

dynamic-load 时,路由有多级路径时找不到拆分的.js文件 #102

Closed
yinlsea opened this issue Sep 23, 2016 · 13 comments
Closed

Comments

@yinlsea
Copy link

yinlsea commented Sep 23, 2016

把user-dashboard示例按照dynamic-load示例只改造router.js,如下:
image
history使用browserHistory时,如果路由到/demo/users路径,则会请求127.0.0.1:8989/demo/0.js,出现404报错
image
history如果使用hashHistory则没有问题,请求的是127.0.0.1:8989/0.js

如果直接路由到/users,则不管是hashHistory还是browserHistory都没有问题。

@yinlsea
Copy link
Author

yinlsea commented Sep 23, 2016

如果直接不采用dynamic-load模式,则路由到多级也是没有问题
image

@sorrycc
Copy link
Member

sorrycc commented Sep 23, 2016

webpack 的 publicPath 配成 / 试试。

@yinlsea
Copy link
Author

yinlsea commented Sep 23, 2016

image

加上publicPath后,根路径的路由/index.js就直接404了.

@xjdata
Copy link

xjdata commented Oct 21, 2016

@yinlsea 请问你的vsc,对react的项目支持如何? 我用默认的,也尝试安装了几个扩展, 但是当遇到{...foo,...bar}格式的语句时,自动格式化就瘫痪了。 又不太想还其他的编辑器,没办法只有手工format。

@ohmyauthentic
Copy link

@xjdata 解析构符号也识别不了,你有什么插件嘛

@sorrycc
Copy link
Member

sorrycc commented Oct 22, 2016

用 idea 或 webstorm 啊,官方更新很快,支持也很全。

@xjdata
Copy link

xjdata commented Oct 22, 2016

@ohmyauthentic 木有~ 没办法换了webstorm~

@yinlsea
Copy link
Author

yinlsea commented Nov 10, 2016

解决了,用browserHistory,按需加载的时候需要这样写:
import { useRouterHistory } from 'dva/router';
import { createHistory } from 'history';

dva({
history: useRouterHistory(createHistory)({basename: ‘ROOTPATH’}),
});

@yinlsea yinlsea closed this as completed Nov 10, 2016
@yinlsea
Copy link
Author

yinlsea commented Nov 10, 2016

解决了,用browserHistory,按需加载的时候需要这样写:
import { useRouterHistory } from 'dva/router';
import { createHistory } from 'history';

dva({
history: useRouterHistory(createHistory)({basename: ‘ROOTPATH’}),
});

1 similar comment
@yinlsea
Copy link
Author

yinlsea commented Nov 10, 2016

解决了,用browserHistory,按需加载的时候需要这样写:
import { useRouterHistory } from 'dva/router';
import { createHistory } from 'history';

dva({
history: useRouterHistory(createHistory)({basename: ‘ROOTPATH’}),
});

@lhg0302
Copy link

lhg0302 commented Dec 27, 2016

你好,我按你的方式解决了子目录的问题,但是现在多级路径,在一级路径入http://localhost:8989/indexpage按f5刷新可以,但是http://localhost:8989/indexpage/test1按f5就不行,报找不到.js文件

@lcy3267
Copy link

lcy3267 commented Jan 16, 2017

@yinlsea 请问下 ROOTPATH是指什么 ,我用Link to='/xx/xx' 可以 顺利进去多级路径,F5刷新进不了i

@yinlsea
Copy link
Author

yinlsea commented Jan 17, 2017

ROOTPATH就是你的根路径,例如:"/XXX/“,访问就是http://IP:PORT/XXX/

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

No branches or pull requests

6 participants