c# - React/ASP - 当前未启用对实验性语法“classProperties”的支持
问题描述
一直在关注一篇文章,其中详细介绍了使用 C# 设置React所需的步骤。但是,每次尝试编译 React 应用程序时都会出现以下错误:
Support for the experimental syntax 'classProperties' isn't currently enabled
onChange = (e) => {
this.setState({ value: parseInt(e.currentTarget.value, 10) });
};
错误消息概述:
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation. If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.
因此,我改变了我的 package.json 以适应:
{
"name": "Test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --config=Scripts/React/config/webpack.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.10.3",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/preset-react": "^7.10.1",
"@babel/preset-env": "^7.2.3",
"babel-preset-react": "^6.23.0",
"babel-loader": "^8.1.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
},
"dependencies": {
"react-countup": "^4.3.3",
"react-router": "^5.2.0",
"react-svg-gauge": "^1.0.10",
"reactstrap": "^8.5.1",
"recharts": "^1.8.5"
},
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
}
尽管如此,我仍然收到同样的错误。有没有人对我如何缓解这个问题有任何想法?
解决方案
试试这个,可能重复对实验语法 'classProperties' 的支持当前未启用
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
推荐阅读
- google-cloud-platform - 在 GCP 文件夹中创建项目需要哪些权限?
- javascript - 将 java 脚本代码转换为 java 类
- python - 如何在python中将dict的键映射到json
- python - 如何在 Django 的一个/单个页面中创建多个表单?
- elasticsearch - Elastic cloud (kibana) 中的默认用户名以及如何找到密码
- c# - 备用键上的 EF Core FK 约束
- shiny - 通过 valueBox() 或 renderValueBox() 渲染 URL
- azure - CosmosDB 的 Spark DataFrame 编写器是否处理空行?
- amazon-web-services - 无法在 Google App 脚本中生成正确的 AWS 签名
- c++ - 矢量/算法与 iostream 不兼容