我使用的是React 0.14.0,React Router 2.0.0-rc4,browserify 11.2.0,babelify 7.2.0。反應路由器末尾的斜槓不起作用
這裏是我的路由器代碼:
render((
<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component={Departments} />
<Route path="goals" component={Goals} />
<Route path="departments" component={Departments} >
<Route path="department" component={Department} />
</Route>
</Route>
</Router>
), document.getElementById('react-container'))
根/部門工作正常,但沒有根/部門/。根/部門/部門也不工作。我不知道爲什麼。
此外,它似乎與任何類型的參數:myParam無法識別。
我看不出我的代碼和文檔中提供的示例有任何區別。
另一個奇怪的是,我沒有警告:
Warning: [react-router] Location "undefined" did not match any routes
我:
Uncaught SyntaxError: Unexpected token < bundle.js:2
如果我點擊bundle.js在Chrome開發人員工具鏈接我到達index.html(但bundle.js是選項卡的名稱)。
如/,出發地和目標的基本路線工作正常。
我有點卡在這個。任何意見將是有益的。
Full code available here:https://github.com/codeforabq/Open-Budget-ABQ/tree/dev
謝謝。
你可以創建一個問題的一小版本小提琴? –
我看了一下你的代碼並啓動了一個服務器,問題沒有反應(還)。它位於server.js和/或您的url中的路由規則中。您正在獲取語法錯誤,因爲它試圖查找/ dist/department中不存在的bundle.js。我正在玩一些東西,當我開始工作時我會發表評論。 –
您在index.html中的資產URL必須是絕對的。在index.html中,將斜線添加到所有鏈接href的開頭,並添加到腳本src的開頭。 –