首页 > 技术文章 > Support for the experimental syntax 'decorators-legacy' isn't currently enabled

bigsister 2020-09-21 10:19 原文

react项目中自己写了一个装饰器,运行的时候发现报错

Support for the experimental syntax 'decorators-legacy' isn't currently enabled

这是因为我们么有装支持装饰器的组件

Support for the experimental syntax 'decorators-legacy' isn't currently enabled

然后 npm run eject

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

增加下面配置

 
"plugins": [
    [
        "@babel/plugin-proposal-decorators",
        {
            "legacy": true
        }
    ]
]

项目重启

文章借鉴于https://blog.csdn.net/qq_41831345/article/details/101287368

推荐阅读