出错信息:
出错的原因:
Support for the experimental syntax ‘classProperties’ isn’t currently enabled
解决方式 一:
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
采用方案一:
npm install --save-dev @babel/plugin-proposal-class-properties
修改 webpack的配置文件(我的是webpack.config.js)
在babel-loader的配置下新增plugins配置项:
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
plugins: [
"@babel/plugin-proposal-class-properties",
babel-loader 详细配置项见: https://www.webpackjs.com/loaders/babel-loader/
webpack配置文件修改后,重启应用即可。
项目中使用高级语法报错,
SyntaxError: E:\workdata\webpackVue\src\index.js: Support for the experimental syntax 'classProperties' isn't currently enabled (22:8):
20 | 21 | class Dog {> 22 | name = '...
解决:根目录新建babel.config.js加入如下内容
module.exports = {
presets: [ "@babel/preset-env", "@babel/preset-react" ],
plugins: [ "@babel/plugin-transform-arrow-functions", "@babel/plugin-proposal-cl...
Webpack中提示syntax ‘classProperties’ isn’t currently enabled的错误
使用了一些JavaScript的一些新特性的时候,但是有没有在webpack.config.js里面或者是.babelrc文件中配置相关插件,就可以解决了。
error:Support ``for` `the experimental syntax ``'classPrope...
今天在es6的class类中定义箭头函数报错Support for the experimental syntax 'classProperties' isn't currently 产生原因解决办法
没有在webpack.config.js里面或者是.babelrc文件中配置相关插件。
下载并配置好即可。
npm i -D @babel/plugin-proposal-cl...