Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 获得;Undefined不是对象(正在评估StyleSheet.create)";反应本机错误_Ios_Reactjs_React Native_React Native Ios - Fatal编程技术网

Ios 获得;Undefined不是对象(正在评估StyleSheet.create)";反应本机错误

Ios 获得;Undefined不是对象(正在评估StyleSheet.create)";反应本机错误,ios,reactjs,react-native,react-native-ios,Ios,Reactjs,React Native,React Native Ios,我对react native很陌生,我正在尝试在我正在创建的应用程序中使用滑动导航。我已经安装了randomcolor,以及native react swipe,但由于某些原因,我仍然收到一个错误 import React, {Component} from 'react'; import Swiper from 'react-native-swiper' import randomcolor from 'randomcolor' const { View, Text, Style

我对react native很陌生,我正在尝试在我正在创建的应用程序中使用滑动导航。我已经安装了randomcolor,以及native react swipe,但由于某些原因,我仍然收到一个错误

import React, {Component} from 'react';
import Swiper from 'react-native-swiper'
import randomcolor from 'randomcolor'

const {
  View,
  Text,
  StyleSheet
} = React

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  view: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  }
});

class TitleText extends React.Component {
  render() {
    return (
      <Text style={{ fontSize: 48, color: 'white' }}>
        {this.props.label}
      </Text>
    )
  }
}

class Home extends React.Component {

  viewStyle() {
    return {
      flex: 1,
      backgroundColor: randomcolor(),
      justifyContent: 'center',
      alignItems: 'center',
    }
  }

  render() {
    return (
      <Swiper
        loop={false}
        showsPagination={false}
        index={1}>
        <View style={this.viewStyle()}>
          <TitleText label="Left" />
        </View>
        <Swiper
          horizontal={false}
          loop={false}
          showsPagination={false}
          index={1}>
          <View style={this.viewStyle()}>
            <TitleText label="Top" />
          </View>
          <View style={this.viewStyle()}>
            <TitleText label="Home" />
          </View>
          <View style={this.viewStyle()}>
            <TitleText label="Bottom" />
          </View>
        </Swiper>        
        <View style={this.viewStyle()}>
          <TitleText label="Right" />
        </View>
      </Swiper>

    )
  }
}

export default Home
import React,{Component}来自'React';
从“react native Swiper”导入Swiper
从“randomcolor”导入randomcolor
常数{
看法
文本,
样式表
}=反应
const styles=StyleSheet.create({
容器:{
弹性:1
},
视图:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
}
});
类TitleText扩展了React.Component{
render(){
返回(
{this.props.label}
)
}
}
类Home扩展了React.Component{
viewStyle(){
返回{
弹性:1,
backgroundColor:randomcolor(),
为内容辩护:“中心”,
对齐项目:“居中”,
}
}
render(){
返回(
)
}
}
导出默认主页
我得到的错误是“undefined不是对象(计算'StyleSheet.create')”。我已经试着破解它有一段时间了,但是没有任何运气。。
这是我的代码,任何帮助都将不胜感激

要访问React Native您需要从
React Native
而不是
React
导入它们

import {
  View,
  Text,
  StyleSheet
} from 'react-native'

要访问React Native,您需要从
React Native
而不是
React
导入它们

import {
  View,
  Text,
  StyleSheet
} from 'react-native'