zoukankan      html  css  js  c++  java
  • 在create-react-app 中启用装饰器语法

    方法一: 暴露create-react-app 配置文件

    • 运行命令:
    nom run eject
    
    • 如果报错,说明需要用git 保存当前文件更改后才能使用上面的命令。
      运行如下git命令:
    git init 
    git add ./
    git commit -m 'init'
    
    • 在 babel 中添加 plugins 配置
      在 package.json 文件中找到 babel 的配置,添加如下代码即可:
    "babel": {
        "presets": [
          "react-app"
        ],
    +    "plugins": [
    +        [
    +            "@babel/plugin-proposal-decorators",
    +            { "legacy": true }
    +        ]
    +    ]
    }
    
    
  • 相关阅读:
    iOS开源控件库收集
    Ruby中的几种除法
    Font
    PlaySound
    STL
    APIs
    cin and cout
    CreateWindow
    Introducing Direct2D
    VC 常用代码
  • 原文地址:https://www.cnblogs.com/liea/p/11823723.html
Copyright © 2011-2022 走看看