在使用react-router-config时,遇到此报错export ‘Switch’ (imported as ‘Switch’) was not found in ‘react-router’
打开react-router中的index.js文件,发现导出的是Routes并非Switch,在react-router-config.js中却引人了Switch,分析是因为版本问题
在项目中把react-router-dom的版本号改成5.x.x,再重新npm i ,可是问题并没有解决,去react-router中一看还是6.x.x的版本
最终简单粗暴的卸载重装
npm uninstall react-router react-router-dom
npm install react-router@5 react-router-dom@5
注意:一定要把react-router也重装,因为package.json文件中看不到react-router,得手动卸载重装