访问不了list页,提示404
来源:10-1 Router概念
行走的指尖
2017-04-18
root.js代码:
import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter } from 'react-router-dom';
import {
BrowserRouter as Router,
Route,
Link,
NavLink
} from 'react-router-dom';
import Index from './index';
import ComponentList from './components/list';
class Root extends React.Component{
render(){
return(
// 这里替换了之前的Index,变成了程序的入口
<Router>
<div>
<Route path="/" component={Index} />
<Route component={ComponentList} path="list" />
</div>
</Router>
)
}
}
ReactDOM.render(<Root/>,document.getElementById('example'));
list.js代码:
import React from "react";
export default class ComponentList extends React.Component{
render(){
return(
<div>
<h2>这里是列表页面</h2>
</div>
);
};
}
可以访问到index.html,但是跳转不到list组件,如下图,list里面没内容。
1回答
-
Parry
2017-04-18
跳转不到是指?没有报错的错误??
032017-09-07
相似问题