相关疑难解决方法(0)

语法错误 - 目前尚未启用对实验语法'decorators-legacy'的支持

我正在尝试用装饰器构建JS反应项目.我的.babelrc看起来像这样:

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react",

  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-transform-object-assign",
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ]
}
Run Code Online (Sandbox Code Playgroud)

添加@ babel/plugin-proposal-decorators问题再次出现.

我使用babel 7,webpack 4并做出反应16.5

webpack.config.js:

const path = require("path");
const webpack = require("webpack");
const componentName = "reports-desktop";
const publicFolderRelativePath = "../../../../../../public/js";
const ignorePlugin = new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/);

module.exports = {
    entry: './reports-desktop.js'
    ,
    output: {
        path: path.resolve(__dirname, publicFolderRelativePath),
        filename: `${componentName}.js`
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader" …
Run Code Online (Sandbox Code Playgroud)

javascript babel

29
推荐指数
6
解决办法
3万
查看次数

标签 统计

babel ×1

javascript ×1