为什么eslint会抛出这个错误?Javascript在React Native内部运行时没有问题.代码取自react-navigation 示例:https://reactnavigation.org/docs/intro/

Javascript:

static navigationOptions = { header: null };

eslint错误:

error  Parsing error: Unexpected token =

埃斯林特先生.js文件:

module.exports = {
    "extends": "standard",
    "plugins": [
      "react",
      "react-native"
    ]
};

推荐答案

语法尚未标准化,但第二阶段建议将其包含在Javascript中(参见第https://github.com/tc39/proposals页的"类字段").

请try 在您的应用程序中的"扩展"上方添加以下选项.eslintrc.js:

"parser": "babel-eslint",

React-native相关问答推荐

FlatList 总是增长到 100% 高度

元素类型无效:应为字符串

是否有用于react-native 的简单同步存储选项?

如何在 react native 中以 redux 形式设置隐藏字段?

React Native - Expo:fontFamily 'SimpleLineIcons' 不是系统字体,尚未通过 Font.loadAsync 加载

Javascript setTimeout 立即在 React Native 中运行

React Native Android:how to remove "overscroll effect" of ScrollView

react-native android中出现此问题Cannot convert argument of type class org.json.JSONArray的原因是什么?

如何以编程方式在 react-native 中截屏

使用 Bearer身份验证令牌react native图像

React Navigation - 标题的渐变 colored颜色

自定义原生基础的选项卡

react-native fetch() cookie 持久化

TypeError : props.navigation.getParam 不是函数. In(props.navigation.getParam('name')

当数据为空时,React-Native FlatList 呈现零状态

在 React-Native 中手动设置 opacity 的 onPress of TouchableOpacity 的音量

动态改变 React Native Flat List 中的列数

Android Log

Mapping children of a parent component

无法解析模块react-native-screen