Javascript “react-router”不包含名为“Link”的导出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44267049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'react-router' does not contain an export named 'Link'
提问by Evhz
I'm using [email protected]
我正在使用 [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected]
and this message appears in development when attaching a react-router Link
附加反应路由器链接时,此消息出现在开发中
./src/containers/FilterLink.js
37:4-8 'react-router' does not contain an export named 'Link'.
This is the import code:
这是导入代码:
import React from 'react';
import { Link } from 'react-router';
By the way changing version to [email protected] seems to be working.
Does anyone know if Link was removed from react-router? what happened with Link?
顺便说一下,将版本更改为 [email protected] 似乎有效。
有谁知道链接是否已从 react-router 中删除?林克怎么了?
If not, why do I get this error?
如果没有,为什么会出现此错误?
回答by lux
4.x introduced some breaking changes, you'll need to import Linkfrom react-router-dom:
4.x 引入了一些重大更改,您需要Link从react-router-dom以下导入:
CommonJS
通用JS
var Link = require('react-router-dom').Link
ES6 Modules
ES6 模块
import { Link } from 'react-router-dom'
Take a peek here for some additional background: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-dom
在这里查看一些其他背景信息:https: //github.com/ReactTraining/react-router/tree/master/packages/react-router-dom

