2016-11-21 8 views
0

私はbrowserHistoryを使用してパスにパラメータを追加しようとしていますが、パスをパラメータに追加するときに、ブラウザが探しているパスが正しくないため、それはURLの前に 'AddAmendLeague'を追加しています。browserHistory:ルータが経路を見つけられない場合

パスはどうあるべきか(http://localhost:8080/Home):

enter image description here

ReactDOM.render(<Router history={browserHistory }> 
       <Route path='*' component={Layout}> 
        <IndexRoute   component={Home}/> 
        <Route path="LeagueList" component={LeagueList}/> 
        <Route path="/AddAmendLeague/:LeagueID" component={AddAmendLeague}/> 
       </Route> 

      </Router>, app); 

インデックス:

enter image description here

http://localhost:8080/AddAmendLeague/1が)今のブラウザは私client.jsを見つけることができません.html

<script src="client.min.js"></script> 

私が間違っていることに関するアイデアはありますか?申し訳ありませんが、これは愚かな間違いです。あなたは私のpackage.JSON

Package.JSON

{ 
    "name": "bableandtypescript", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "dev": "webpack-dev-server --content-base src --inline --hot --watch --history-api-fallback" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "babel-core": "^6.17.0", 
    "babel-loader": "^6.2.5", 
    "babel-plugin-add-module-exports": "^0.2.1", 
    "babel-plugin-react-html-attrs": "^2.0.0", 
    "babel-plugin-transform-class-properties": "^6.16.0", 
    "babel-plugin-transform-decorators-legacy": "^1.3.4", 
    "babel-preset-es2015": "^6.16.0", 
    "babel-preset-react": "^6.16.0", 
    "babel-preset-stage-0": "^6.16.0", 
    "debug": "^2.3.2", 
    "es6-promise": "^4.0.5", 
    "flux": "^3.0.0", 
    "history": "^4.3.0", 
    "json-loader": "^0.5.4", 
    "mysql": "^2.12.0", 
    "net": "^1.0.2", 
    "radium": "^0.18.1", 
    "react": "^15.3.2", 
    "react-dom": "^15.3.2", 
    "react-router": "^2.8.1", 
    "undebug": "^1.0.0", 
    "webpack": "^1.13.2", 
    "webpack-dev-server": "^1.16.2", 
    "websocket": "^1.0.23" 
    } 
} 

答えて

0

が必要な場合は

あまりにもわからない私は、私はあなたの質問を右に理解してかはわかりません。しかし、多分あなたは、あなたはまた、あなたがすべきbrowserHistoryであなたが素敵なURLをしたい場合は「/」、ハッシュ#タグ(http://localhost:8080/#/AddAmendLeague/1

でURLを使用することができ、あなたがhttps://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#hashhistory

をルーティングするためhashhistoryの代わりbrowserhistoryを使用する必要がありますこのURLを処理するようにサーバーを設定してください。https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#configuring-your-server

+0

こんにちは、hashHistoryは機能しますが、見栄えの良いURLを維持しようとしています。ブラウザ履歴ルートはhashHistoryとは異なる動作をしますか? –

+0

あなたの質問に基づいて、このコード行はあなたには分かりません。 この行はAddAmendLeagueに行き、LeagueIDというパラメータを持つことを示します。あなたの質問を理解していないのですか? –

+0

welcomeブラウザの素晴らしいURLが必要な場合は、サーバーを設定する必要があります(https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#configuring-your-server) –

関連する問題