0

私は別のコンポーネントにページをリダイレクトしようとしていますが、私はdid not match any routeエラーを受け取ります。反応ルータがどのルートとも一致しません

"react-router": "2.4.0", 
"react-router-redux": "4.0.4", 

Webpack.configファイル:出力:

output: { 
    path: __dirname + '/dist', 
    publicPath: '/SurveyMaintenance/', 
    filename: 'bundle.js' 
    } 

アプリの起動:

import {Router, browserHistory} from 'react-router'; 
import routes from './routes'; 

    <Provider store={store}> 
     <Router history={browserHistory} routes={routes} /> 
    </Provider>, 
    document.getElementById('app') 
); 

私Route.jsファイル:

<Route path="SurveyMaintenance/" component={App}> 
     <IndexRoute component={SurveyMaintenancePage}/> 
     <Route path="surveydetail/:id" component={EditSurveyPage} /> 
    </Route> 

はルータバージョンに反応します

リンク要素:

<Link to={`surveydetail/${survey.Id}`} onClick={editSurvey}></Link> 

エラー:enter image description here 住所: enter image description here

アドレスが正しいに見えるが、明らかにそのアドレスに割り当てられているコンポーネントがある場合、まだそのはこのエラーを投げます。 私は間違ったことをする必要があります。あなたは完全なパスを使用する必要があり、最後のスラッシュを必要としない、あなたもpublicPath: '/'

<Route path="SurveyMaintenance" component={App}> 
      <IndexRoute component={SurveyMaintenancePage}/> 
      <Route path="surveydetail/:id" component={EditSurveyPage} /> 
     </Route> 

設定する必要が

答えて

0

私はsurveydetailの前に '/'を追加するだけでこの問題を解決しました。このような。

<Route path="SurveyMaintenance" component={App}> 
      <IndexRoute component={SurveyMaintenancePage}/> 
      <Route path="/surveydetail/:id" component={EditSurveyPage} /> 
     </Route> 

<Link to={`surveydetail/${survey.Id}`} onClick={editSurvey}></Link> 
私はちょうどあなたがお勧めとアドレス何しようとした
0

- あなたはpublicPathを使用したい場合は

<Link to={`/SurveyMaintenance/surveydetail/${survey.Id}`} onClick={editSurvey}></Link> 

を、あなたはこのような履歴のベース名を追加する必要があります How to configure a basename in React Router 3.x

+0

とき: ます。http:// localhostを:3000/SurveyMaintenance/SurveyMaintenance/surveydetail/449 – vineeth

+0

更新の答えを参照してください、あなたはbasePathを設定する必要があります: '/' または反応ルータにベース名を追加してください – Kossel

+0

待機していますが、URLが間違っています – vineeth

関連する問題