相关疑难解决方法(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万
查看次数

元素描述符的.kind属性必须为“方法”或“字段”

我正在关注文档,mobx-react-router但是尝试运行我的应用程序时,在浏览器中出现以下错误:

Uncaught TypeError: An element descriptor's .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "undefined"
    at _toElementDescriptor (app.js:49988)
    at _toElementFinisherExtras (app.js:49990)
    at _decorateElement (app.js:49980)
    at app.js:49976
    at Array.forEach (<anonymous>)
    at _decorateClass (app.js:49976)
    at _decorate (app.js:49958)
    at Module../src/App/UserStore.js (app.js:50012)
    at __webpack_require__ (bootstrap:19)
    at Module../src/index.js (index.js:1)
Run Code Online (Sandbox Code Playgroud)

这是我初始化的方式:

const appContainer = document.getElementById('app');
if(appContainer) {
  const browserHistory = createBrowserHistory()
  const routingStore = new RouterStore();

  const stores = {
    users: userStore,
    routing: routingStore
  } …
Run Code Online (Sandbox Code Playgroud)

mobx mobx-react

0
推荐指数
1
解决办法
1345
查看次数

标签 统计

babel ×1

javascript ×1

mobx ×1

mobx-react ×1