使用默认 StyleSheet React Native 的动态 inilne 样式
Dynamic inilne style with default StyleSheet React Native
我需要给动态内联样式和静态默认样式表样式。我怎样才能做到这一点
<View
style={[styles.card,{{width:width, height: height}}]}>
<View style={styles.card}>
<Text>
<Image
source={{uri: this.props.media.image_url}}
style={{width:width, height: this.props.media.height}}/>
</Text>
</View>
</View>
以上代码对我不起作用。
经过多次尝试终于解决了。
这是代码
<View
<View style={[{width:width, height: height},styles.card]}>
<View style={styles.card}>
<Text>
<Image
source={{uri: this.props.media.image_url}}
style={{width:width, height: this.props.media.height}}/>
</Text>
</View>
</View>
</View>
不,问题不在于顺序,您没有正确传递动态(内联样式)。您将它们包裹在额外的花括号中
改变这个:
style={[styles.card,{{width:width, height: height}}]}
至:
style={[styles.card,{width:width, height: height}]}
你在上面的回答中实际上做了同样的事情。
我需要给动态内联样式和静态默认样式表样式。我怎样才能做到这一点
<View
style={[styles.card,{{width:width, height: height}}]}>
<View style={styles.card}>
<Text>
<Image
source={{uri: this.props.media.image_url}}
style={{width:width, height: this.props.media.height}}/>
</Text>
</View>
</View>
以上代码对我不起作用。
经过多次尝试终于解决了。 这是代码
<View
<View style={[{width:width, height: height},styles.card]}>
<View style={styles.card}>
<Text>
<Image
source={{uri: this.props.media.image_url}}
style={{width:width, height: this.props.media.height}}/>
</Text>
</View>
</View>
</View>
不,问题不在于顺序,您没有正确传递动态(内联样式)。您将它们包裹在额外的花括号中
改变这个:
style={[styles.card,{{width:width, height: height}}]}
至:
style={[styles.card,{width:width, height: height}]}
你在上面的回答中实际上做了同样的事情。