2016-05-25 2 views
-1

どうすればいいですか?特に、パスの一部がparam(:someParam)であるとき。私はドキュメントで何も見つけることができません。リアクタとの相対的なリンク

+0

少し良く説明できますか?例を挙げる。 – Chris

+0

ありがとうと、それのためのパッケージがあります。 https://github.com/ryanflorence/react-router-relative-links。 – omgj

答えて

0

今反応し、ルータ3をこのシナリオ https://github.com/ReactTraining/react-router/issues/3325

反応-ルータを2.xでこの問題を持つ人にとって使用することをお勧めします:

あなたは相対的なルートをサポートするためにbrowserHistoryを使用することができ、代わりにリンクコンポーネントを使用します。

// assuming http://site/myanimals 

    // configure router for hosting in subdirectory 
    const history = useRouterHistory(createHistory)({ 
     basename: '/myanimals' 
    }); 

    // then use it ... 
    import {browserHistory} from 'react-router'; 

    browserHistory.push('about'); 

    // or, for a configured route with 'animal/:id' you can use 

    // <Route path={'animal:id'} .../>   
    browserHistory.push('animal/3'); 

関連する問題