Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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
Reactjs react native stylesheet.create函数返回的是映射的数字,而不是样式规则_Reactjs_React Native_Stylesheet - Fatal编程技术网

Reactjs react native stylesheet.create函数返回的是映射的数字,而不是样式规则

Reactjs react native stylesheet.create函数返回的是映射的数字,而不是样式规则,reactjs,react-native,stylesheet,Reactjs,React Native,Stylesheet,我在react组件的底部声明了一个简单的样式表 const styles = StyleSheet.create({ start:{ flex:1 }, text:{ color: "red", fontSize: 24, flex: 1 }, separator:{ height: 2, backgroundColor: "white" } }); 当我尝试引用这些样式中的任何一种时,我得到的是一个数字,而不是样式规则 export default class ShowGalle

我在react组件的底部声明了一个简单的样式表

const styles = StyleSheet.create({
start:{
 flex:1
},
text:{
 color: "red",
 fontSize: 24,
 flex: 1
},
separator:{
 height: 2,
 backgroundColor: "white"
}
});
当我尝试引用这些样式中的任何一种时,我得到的是一个数字,而不是样式规则

export default class ShowGallery extends Component{
  render(){
     return(
       <View>
         <Text style={styles.text}>Test </Text>
       </View>
    )
 }
}
导出默认类ShowGallery扩展组件{
render(){
返回(
试验
)
}
}

这里是styles.text返回193?顺便说一下,我正在使用react原生版本37.0,这实际上是
样式表的性能增强
使用
样式表将样式从JS端传输到本机端可能非常昂贵。create
样式会提前通过桥发送,并由本机端“缓存”


然后将各个数字用作JS端和本机端之间的参考,以了解要使用的样式。

如果使用
StyleSheet.create()
,这是正常行为。如果需要访问样式对象,可以使用
StyleSheet.flatte(styles.text)
。链接到