【发布时间】:2018-07-21 18:56:57
【问题描述】:
我有一个十六进制颜色,通过这个文件中的道具接收,十六进制代码是'#BE2625'。在它正确显示但是当我将相同的应用于 backgroundColor 时,颜色不会显示,而是会向我发出警告
警告:道具类型失败:提供给视图的道具“背景颜色”无效:“#BE2625”有效颜色格式为.......
import React from 'react';
import {StyleSheet, View, Text} from 'react-native'
export default class Color extends React.Component {
render() {
const {Color} = this.props;
return (
<View style={[styles.bodyColor, {backgroundColor: `'${Color}'` }]}>
<Text style={styles.hex}> {Color} </Text>
</View>
);
}
}
const styles = StyleSheet.create({
bodyColor :{
height:50,
margin:10,
},
hex :{
textAlign:'center',
fontSize: 22,
padding:10
}
})
【问题讨论】: