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


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM