Attempted import error: ‘Link’ is not exported from ‘react-router’.

2019-04-26 09:36   Tags:

根据官方文档这么引入

import { Router, Route, Link } from 'react-router'

但是,报这个错误:Attempted import error: 'Link' is not exported from 'react-router'.

需要这么做

安装react-router-dom

npm i react-router-dom -S

引入

import { BrowserRouter as Router, Route, Link } from "react-router-dom";

详情:

https://reacttraining.com/react-router/web/guides/quick-start

发表评论

电子邮件地址不会被公开。 必填项已用*标注