在vscode编辑器中使用react-redux @connect发生报错的问题解决

在学习Redux+React Router+Node.js全栈开发时,遇到使用react-redux的@connect装饰器报错。错误信息指出需要提供'decoratorsBeforeExport'选项。原因在于项目使用了Babel 7.x,而当前配置适配的是Babel 6。解决方案是按照npm官网指示,安装@babel/plugin-proposal-decorators,并更新package.json配置。若vscode仍有错误提示,需创建jsconfig.json文件。
摘要由CSDN通过智能技术生成

在慕课网Redux+React Router+Node.js全栈开发的学习中我遇到了一个问题

当使用react-redux的@connet装饰器时发生了报错,为什么编辑的和学习视频中相同,但会报错,而且运行后也产生了error。

当时我的package.json中用的是“transform-decorators-leagacy”这个插件,在项目中安装的是"babel-plugin-transform-decorators-legacy": "^1.3.5",

"plugins": [
      "transform-decorators-legacy",
      [
        "import",
        {
          "libraryName": "antd-mobile",
          "style": "css"
        }
      ]
    ]

产生了错误:Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.

这是因为上面的配置是使用babel6时的配置,

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值