如何将样式数组应用于基于本机的组件?我有这样的风格:
const React = require('react-native');
const { StyleSheet } = React;
export default StyleSheet.create({
container: {
backgroundColor: '#FBFAFA',
},
rowView:{
flexDirection: 'row',
borderRadius: 5
},
btn : {
borderRadius: 5,
margin: 5
},
on : {
backgroundColor: '#FFF',
},
off : {
backgroundColor: 'rgba(0,0,0,0.2)',
},
green : {
backgroundColor: 'green',
},
red : {
backgroundColor: 'red',
}
});我想应用于这样的组件:
<View style={[styles.red, styles.rowView]} padder>我在原生库中看到他们使用getTheme。这是唯一的办法吗?
发布于 2017-06-21 04:29:36
目前,本机基础不支持style属性中的数组。以下是使用展开运算符的解决方法。
<Native-Base-Component style={{ ...styles.red, ...styles.rowView }} />https://stackoverflow.com/questions/43930439
复制相似问题