react 项目支持装饰器写法 Support for the experimental syntax 'decorators-legacy' isn't currently enabled

1、添加babel插件

yarn add @babel/plugin-proposal-decorators

2、暴露脚手架配置

yarn run eject
react 项目支持装饰器写法 Support for the experimental syntax 'decorators-legacy' isn't currently enabled_第1张图片
报错信息.png

3、添加版本

git add .
git commit -m 'message'

在重新执行1、2

添加配置信息

"plugins": [
    ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }]
  ]
react 项目支持装饰器写法 Support for the experimental syntax 'decorators-legacy' isn't currently enabled_第2张图片
配置信息.png
tips:装饰器语法是实验性语法,未来不一定会被采用,所以不会被明确使用,不是一个标准

如何使用装饰器

你可能感兴趣的:(react 项目支持装饰器写法 Support for the experimental syntax 'decorators-legacy' isn't currently enabled)