我创建了简单的网络应用程序并尝试连接react-router-dom
,当我启动应用程序时,它显示了组件Audience
(网址:localhost:3000
) ,但如果我将网址更改为localhost:3000/board
或localhost:3000/speaker
,则会显示Cannot GET /board
或Cannot GET /speaker
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import Audience from './components/Audience.jsx';
import Board from './components/Board.jsx';
import Speaker from './components/Speaker.jsx';
ReactDOM.render(
<Router>
<div>
<Route path="/" component={Audience}/>
<Route path="/board" component={Board}/>
<Route path="/speaker" component={Speaker}/>
</div>
</Router>, document.getElementById('root'))
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"><div>
&#13;