4

关于React中使用路由标签Switch报错问题

 2 years ago
source link: https://segmentfault.com/a/1190000040953061
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

关于React中使用路由标签Switch报错问题

发布于 今天 14:10
启动报错:'Switch' is not exported from 'react-router-dom'.

解答:
1、因为默认安装都是最新版本,所以如果你是新手的话,对各个版本更新的内容变化并不了解,因此遇到这种事很头疼的问题,这个得自行学习了解
2、这个报错是版本问题,react-douter-dom@v6中将Switch改成了Routes,因此报错,
所以第一种解决办法:
npm uninstall react-router-dom
npm install [email protected]
第二种解决办法:就去用react-douter-dom@v6版本的语法
3、自己去了解一下版本的更新细节


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK