doubleyong
管理员
管理员
  • 最后登录2024-04-18
  • 发帖数1167
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:3186回复:0

[前端]【react】Support for the experimental syntax 'decorators-legacy' isn't currently enabled

楼主#
更多 发布于:2020-08-03 15:49
问题:
react项目中自己写了一个装饰器,运行的时候发现报错
Support for the experimental syntax 'decorators-legacy' isn't currently enabled


原因:这是因为项目中使用了支持装饰器的组件



解决方案:
执行 npm run eject


在package.json文件下找到bebel属性


增加下面配置


"plugins": [
      [
        "@babel/plugin-proposal-decorators",
        {
          "legacy": true
        }
      ]
    ]
重启项目就OK了参考:https://blog.csdn.net/qq_41831345/article/details/101287368
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号