2015-10-14 44 views
3

我正在尝试在我的反应和redux应用程序中进行路由,但仍然不是运气。react router + restorex警告:位置“xyz”与任何路径不匹配

index.js:

import React from 'react'; 
import { render } from 'react-dom'; 
import { Router, Route, IndexRoute } from 'react-router'; 
import { Provider } from 'react-redux'; 
import { createHistory } from 'history'; 

import DashboardApp from './containers/App'; 
import QuizApp from './containers/QuizApp'; 
import Page from './containers/Page'; 
import store from './store'; 

const routes = <Router history={createHistory()}> 
    <Route path="/" component={Page}> 
     <IndexRoute component={DashboardApp} /> 
     <Route path="quiz" component={QuizApp} /> 
    </Route> 
</Router>; 

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

默认视图被适当地生成的。在DashboardApp我有这样的代码:

<Link to='quiz'>Quiz</Link> 

如果我点击它,我得到错误控制台:

Warning: Location "quiz" did not match any routes 

我将不胜感激任何提示怎么解决呢

回答

1

你需要使用绝对路径而不是名称。

<Link to='/quiz'>Quiz</Link>

见链接组件文档中描述here

+0

当然:d非常感谢! – Kania

相关问题