1、下载相关依赖npm ireact-router-config -s
npm i react-router-dom -s
2、在index.js上引入import { hashrouterasrouter } from ' react-router-DOM '
3、在app.js中引入import { link } from ' react-router-DOM '
导入{ render routes } from ' react-router-config ';
importroutesfrom './routers/router '
4、新建routers文件夹,导入组件
5、页面是这样写的
6、恢复项目
7、如果搞错了' switch ' isnotexportedfrom ' react-router '。
降低原始路由器- DOM的版本
首先删除现有版本
npm uninstall react-router-dom下载旧版本
npminstallreact-router-DOM @5.2. 0