1

如何将样式数组应用于原生组件?我有这种风格:

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。这是唯一的方法吗?

4

1 回答 1

0

目前 native-base 不支持 style 属性中的数组。这是使用扩展运算符的解决方法。

<Native-Base-Component style={{ ...styles.red, ...styles.rowView }} />
于 2017-06-20T20:29:36.297 回答