React router:在动态路由刷新错误中嵌套静态路由

时间:2016-02-23 18:45:41

标签: reactjs react-router

我在react-router 2.0.0-rc中遇到了browserHistory的问题。我试图通过使用用户名的react-router参数来获得一个编辑页面,然后是一个名为“edit”的嵌套静态路由。当我使用react-router链接时,页面会按预期加载,但在手动输入URL或刷新后,页面显示为空白且包含错误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>

1 个答案:

答案 0 :(得分:5)

我明白了。我需要在我的index.html中将/放在我的bundle和css文件之前。我的其他路线很好,因为它们是顶级路线,但是一旦我进入嵌套路线,我就失去了对静态资产的引用。

相关问题