我在react-router 2.0.0-rc中的browserHistory有问题。我试图通过使用用户名的react-router参数,然后是称为“ edit”的嵌套静态路由,来使编辑页面正常工作。当我使用react-router链接时,页面按预期加载,但是在手动输入或刷新URL后,页面显示为空白,并显示bundle错误Uncaught SyntaxError: Unexpected token <
。
我所有其他路线都工作正常。不幸的是,所有文档似乎都使用静态参数,然后使用动态路由参数,而不是相反。
这是我的路线:
<Route path="/" component={App} onEnter={currentUserCheck}>
<IndexRoute component={HomePage} />
<Route path="/signup" component={SignupForm} />
<Route path="/login" component={LoginForm} />
<Route path="/chart" component={PollResult} />
<Route path="/:username/edit" component={EditProfile}/>
<Route path="/:username" component={ProfilePage}/>
<Route path="*" component={NoMatch}/>
</Route>
我想到了。我需要/
在我的bundle和css文件之前放入index.html。使用其他路线时,我感觉很好,因为它们是顶级路线,但是当我移入嵌套路线后,便失去了对静态资产的参考。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句