我创建了样式,但有时我无法使用它们,因为它们返回数字:
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#FFFFFF'
},
moodSliderContainer: {
justifyContent: 'center',
alignItems: 'center',
width: '100%'
},
postListContainer: {
width: '100%',
height: '100%',
paddingBottom: 120
}
});
console.log(styles);
最佳答案
来自 React Native documentation - StyleSheet :
Performance:
Making a stylesheet from a style object makes it possible to refer to it by ID instead of creating a new style object every time.
It also allows to send the style only once through the bridge. All subsequent uses are going to refer an id (not implemented yet).
如果要检索实际样式对象,可以使用
StyleSheet.flatten(styles.container)
.
关于react-native - React Native : Why does stylesheet. 创建带有数字而不是样式的返回对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49782275/