Javascript ReferenceError:未定义Expo

Javascript ReferenceError:未定义Expo,javascript,reactjs,react-native,frontend,expo,Javascript,Reactjs,React Native,Frontend,Expo,我是个新来的本地人。我试图在代码中使用EXPO。但它说的是参考错误:世博会并没有被定义为本地的 class Main extends Component { render() { return ( <View style={{flex:1, paddingTop: Platform.OS === 'ios' ? 0 : Expo.Constants.statusBarHeight }}> </View> )

我是个新来的本地人。我试图在代码中使用EXPO。但它说的是参考错误:世博会并没有被定义为本地的

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

像这样安装expo常量
expo安装expo常量

import Constants from 'expo-constants';

class Main extends Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          paddingTop: Platform.OS === 'ios' ? 0 : Constants.statusBarHeight,
        }}
      />
    );
  }
}
从“expo常量”导入常量;
类主扩展组件{
render(){
返回(
);
}
}

来源:

像这样安装expo常量
expo安装expo常量

import Constants from 'expo-constants';

class Main extends Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          paddingTop: Platform.OS === 'ios' ? 0 : Constants.statusBarHeight,
        }}
      />
    );
  }
}
从“expo常量”导入常量;
类主扩展组件{
render(){
返回(
);
}
}

来源:

就像巴斯范德林登说的那样,你需要导入常量

import { Constants } from 'expo';
但您还需要从react native导入平台

import { Platform } from 'react-native';

就像巴斯范德林登说的,你需要导入常量

import { Constants } from 'expo';
但您还需要从react native导入平台

import { Platform } from 'react-native';