react-native:如何覆盖组件中定义的默认样式

jas*_*hen 17 react-native

假设我想使用具有以下定义样式的Component:

var styles = StyleSheet.create({
  container: {
    backgroundColor: '#ffffff'
  },
});
Run Code Online (Sandbox Code Playgroud)

我能像这样覆盖我的基本风格吗?

<Component style={backgroundColor: 'transparent'}></Component>
Run Code Online (Sandbox Code Playgroud)

它对我不起作用,所以想知道这是否取决于Component是否支持该行为.

d-v*_*ine 30

描述有点模糊.它是你写下自己的一个组成部分吗?假设它应该像这样工作:

export default React.createClass({
  render: function(){
    return(<View style={[ styles.container, this.props.style ]}>...</View>
  }
})

var styles = StyleSheet.create({
  container: {
    backgroundColor: '#ffffff'
  },
});
Run Code Online (Sandbox Code Playgroud)