<Route component={ComList} path='/list'></Route>无法访问
来源:10-1 Router概念
慕无忌0079048
2017-12-07
router.js文件内容如下(该文件路径src/router.js):
import React from 'react';
import ReactDom from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom';
import Index from './index';
import ComList from './components/list';
export default class Root extends React.Component {
render() {
console.log(Index);
return (
<BrowserRouter >
<div>
<Route component={Index} path='/'></Route>
<Route component={ComList} path='/list'></Route>
</div>
</BrowserRouter>
);
}
}
ReactDom.render(
<Root />,
document.getElementById('example')
);
写回答
2回答
-
添加 exact 参数。
<Route exact component={Index} path='/'></Route>032017-12-08 -
Parry
2017-12-07
你 list 的路由定义在哪里?
012017-12-07
相似问题