2016-07-24 19 views
0

제목과 마찬가지로 url의 끝에 #을 추가하지 못하게 할 수 있습니다.반응 라우터가 URL을 # 추가하는 것을 방지하려면 어떻게해야합니까?

내가 일을 많이 시도하지만 #없이 링크를 가져올 수 없습니다 blank1.jsx

method(current,previous){ 
    const category= this.props.params.category; 
    const page = current; 
    const path = `/pathName/${category}/${page}`; 
    browserHistory.push(path); 
... 
} 

(export default (withHistory, onUpdate) => { 
const history = withHistory? 
       (Modernizr.history ? 
       browserHistory 
       : hashHistory) 
      : null; 
return (
<Router history={history} onUpdate={onUpdate}> 
    <Route path='/' component={App}> 
    <IndexRoute component={quotes} /> 
    <Route path='/app/search' component={SimpleSearch} /> 

    <Route path='pathName' component={Blank1} /> 
     <Route path='pathName/:category' component={Blank1}/> 
     <Route path='pathName/:category(/:page)' component={Blank1}/> 
    <Route path='app/:id' component={Blank1} /> 

    </Route> 

</Router> 

); 
}; 

방법

을 routes.jsx. 끝에 #가 추가되고 this.setState로 상태를 변경하는 구성 요소 WillReceiveProps가 계속 트리거됩니다. 그리고 네비게이션에서 탐색 항목 중 아무 것도 활성화되어 있지 않기 때문에 #

+1

내 server.js에 해시 –

답변

0

clean URL을 참조하십시오.

당신 대신 당신은 모든 요청을 통해 라우팅 라우터 반응하는 그래서, 서버에 * 경로를 추가 할 필요가 hasHistory/

browserHistory를 사용하고 싶습니다. 서버 경로의 끝에이 같은

뭔가 더 자세한 정보를 원하시면 체크 아웃 this example

+0

없이 URL을 얻을 수 browserHistory을 사용해야 들어

app.get('*', function (req, res) { res.sendFile(path.join(__dirname, 'public', 'index.html')) }); 

은 내가 응용 프로그램을 가지고있다. get ('*', function (req, res, next) { renderHTML (req, res, next); }}); –

관련 문제