'Switch' is not exported from 'react-router-dom'.

踩坑记录:react-router-dom 从 v6.x 版本开始,移除了Switch,需要做以下变更:

之前:
import { Switch, Route } from "react-router-dom";
改为:
import { Routes ,Route } from 'react-router-dom';

之前:

改为:
} />

其他:
移除 exact 此后不需要在路由中进行声明!

更多修改请访问官方文档
https://reactrouter.com/docs/en/v6/upgrading/v5

你可能感兴趣的:('Switch' is not exported from 'react-router-dom'.)