【发布时间】:2021-01-02 07:56:21
【问题描述】:
我将Truncate-react 添加到我的项目中。之后,React 告诉我需要安装 @babel/plugin-proposal-class-properties,我在 package.json 文件中是这样安装的:
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
当然,proposal-class-properties 本身是我用标签 --save-dev
【问题讨论】:
-
你有什么 babel 版本?你是如何使用 babel 的?使用 webpack?
-
@Liron
"@babel/core": "7.9.0"通过npm run eject在反应中使用,我在 package.json 中编写了 babel 代码 -
有什么方法可以分享你的项目吗?
-
@Liron github.com/AndreyFreiz/Hulu repos
-
好的..所以你必须做两件事才能让它工作。 1. 你的 package.json 中有 .babelrc 文件和 babel 配置。你可以选择一个。 2. 您必须在 VideoCard 组件中将
import TextTruncate from 'react-text-truncate/src/TextTruncate'更改为 `import TextTruncate from 'react-text-truncate'。我假设 react-text-truncate/src/TextTruncate 这个文件不是编译后的版本
标签: javascript reactjs babeljs