我正在使用react路由器1.0.0-rc1和redux。React路由器路由但顯示錯誤消息
這是路線:
<Route path=""component={Body}>
<Route path="machines/:id" component={SingleMachineView}/>
<IndexRoute component={Dashboard}/>
<Route path="*" component={Dashboard}/>
</Route>
這是鏈接:
<Link to={`machines/${machine.machine_id}`}>
{machine.name}
</Link>
該路由器是如何開始:
class Root extends React.Component {
render() {
const history = createHashHistory();
return (
<Provider store={store}>
{() => <Router history={history} children={Routes}/>}
</Provider>
);
}
}
ReactDOM.render(<Root/>, document.getElementById('app'));
一切正常,但是當我點擊鏈接並呈現新視圖我仍然在控制檯中收到錯誤消息:
Warning: Location "machines/id2" did not match any routes
而且當我加載與路徑localhost:8080/#/machines/id2
有什麼點擊鏈接時瀏覽器中的確切網址? – Clarkie
'http:// localhost:8080 /#/ machines/id0?_k = cjqdch',btw我不知道'?_k = cjqdch'來自哪裏。 –
@AndreasKöberle[什麼是?_k = cdjk](https://github.com/rackt/react-router/blob/master/docs/guides/basics/Histories.md#what-is-that-_kckuvup-junk-在網址) – knowbody