2017-07-28 100 views
0
import React, { Component } from 'react'; 
import { View, Text, StyleSheet, TouchableHighlight } from 'react-native'; 

class First extends Component { 
render() { 
    return (
     <View style = {styles.container}> 
      <Text> 
       Hello world! 
      </Text> 
     </View> 
    ); 
    } 
} 

const styles = StyleSheet.create ({ 
container: { 
    backgroundColor: 'yellow', 
    flex: 1 
} 
}); 


module.exports = First; 

此代码填写在项目的黄色画面开始react-native init但显示没有在项目启动时create-react-native-app。这是正常的吗?阵营母语:Flex的行为不同

编辑:这是从App.js中错误地从风格View调用的。

+0

“_but does not the same_”,它还有什么作用? –

+0

@KhalilKhalaf它什么也没有显示。 –

回答

0

它会帮助你

import React, { Component } from 'react'; 
import { View, Text, StyleSheet, TouchableHighlight } from 'react-  
native'; 

class First extends Component { 
render() { 
return (
    <View> 
     <Text style = {styles.container}> 
      Hello world! 
     </Text> 
    </View> 
    ); 
    } 
    } 

const styles = StyleSheet.create ({ 
container: { 
backgroundColor: 'yellow', 
flex: 1 
} 
}); 


module.exports = First; 
+0

返回相同的结果。 –

+0

使用颜色代替backgroundcolor –

0

我用你的代码,并使用create-react-native-app创建应用程序,并显示在顶部文本hello world!黄色底色离开

这里,我不得不the-result-using-create-react-native-app

结果

也许你应该使用create-react-native-add命令创建另一个测试应用并查看结果

1

愚蠢的错误;我从App.js的主题View中调用这个组件。感谢您花时间帮忙,伙计们。

相关问题