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