Your import(您的进口)
import {BrowserRouter as Router, Route} from "react-router";
should be(应该)
import {BrowserRouter as Router, Route} from "react-router-dom";
A note from the react-router
npm package page:(来自react-router
npm软件包页面的注释:)
Note: This package provides the core routing functionality for React Router, but you might not want to install it directly.(注意:这个包提供了React Router的核心路由功能,但是您可能不想直接安装它。) If you are writing an application that will run in the browser, you should instead install react-router-dom
.(如果要编写将在浏览器中运行的应用程序,则应安装react-router-dom
。) Similarly, if you are writing a React Native application, you should instead install react-router-native
.(同样,如果您正在编写React Native应用程序,则应该安装react-router-native
。) Both of those will install react-router
as a dependency.(这两个都将安装react-router
作为依赖项。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…