为什么' react-router-dom'显示'无法获得'

时间:2017-07-19 08:05:53

标签: javascript reactjs routes react-router react-router-dom

我创建了简单的网络应用程序并尝试连接react-router-dom,当我启动应用程序时,它显示了组件Audience(网址:localhost:3000) ,但如果我将网址更改为localhost:3000/boardlocalhost:3000/speaker,则会显示Cannot GET /boardCannot 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;
&#13;
&#13;

0 个答案:

没有答案