繁体   English   中英

ReferenceError: Expo 未定义-React-Native

[英]ReferenceError: Expo is not defined-React-Native

我是 react-native 的新手。 我尝试在我的代码中使用 EXPO 。 但它说的是 ReferenceError: Expo is not defined-React-Native

 class Main extends Component {
  
  render() {
 
    return (
      <View style={{flex:1, paddingTop: Platform.OS === 'ios' ? 0 : Expo.Constants.statusBarHeight }}>
     
     </View>
    );
  }
}

安装 expo 常量,如expo install expo-constants

import Constants from 'expo-constants';

class Main extends Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          paddingTop: Platform.OS === 'ios' ? 0 : Constants.statusBarHeight,
        }}
      />
    );
  }
}

来源: https://docs.expo.io/versions/latest/sdk/constants/

就像 Bas van der Linden 所说,您需要导入常量。

import { Constants } from 'expo';

但是您还需要从 react-native 导入平台

import { Platform } from 'react-native';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM