美文网首页ReactNative开发
在ReactNative中使用ES7语法

在ReactNative中使用ES7语法

作者: peaktan | 来源:发表于2019-05-28 14:58 被阅读0次
1、安装如下插件
yarn add @babel/plugin-proposal-decorators --dev
2、配置babel.config.js
{
  "presets": ["react-native"],
  "plugins":[["@babel/plugin-proposal-decorators", { "legacy": true }]]
}

配置完上面的操作之后重新command+R重载程序就不会报错了,但是VSCode还是会报红,解决方案如下:

3、Error warning message: "Experimental support for decorators is a feature that is subject to change in a future release" 解决方案

进入 VSCode->Settings->User 设置,搜索experimentalDecorators,然后勾选->ok

参考文章

如何在升级后的react-native中使用装饰器

相关文章

网友评论

    本文标题:在ReactNative中使用ES7语法

    本文链接:https://www.haomeiwen.com/subject/iixktctx.html