我在更改视图以响应路由时遇到麻烦。我只想显示一个用户列表,单击每个用户应导航到详细信息页面。这是路由器:
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from 'react-router-dom';
import Users from "./components/Users";
import { Router, Route } from "react-router";
import Details from "./components/Details";
ReactDOM.render((
<BrowserRouter>
<div>
<Route path="/" component={Users} />
<Route path="/details" component={Details} />
</div>
</BrowserRouter>
), document.getElementById('app'))
当我使用url / details时,我的浏览器会导航到该url,但不会更改视图。任何其他路由都会抛出404,因此似乎可以识别该路由,但无法更新。