如何将样式数组应用于基于本机的组件

时间:2017-05-12 06:09:00

标签: react-native native-base

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

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

1 个答案:

答案 0 :(得分:0)

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

<Native-Base-Component style={{ ...styles.red, ...styles.rowView }} />
相关问题