【发布时间】:2019-01-20 02:02:49
【问题描述】:
我是原生反应的新手,并且正在创建我的第一个。
在我的添加中,我决定动态更改我的应用程序的背景颜色,为此我做了类似的事情
let style = StyleSheet.flatten({
upperRow: {
display: "flex",
flexDirection: "row",
marginBottom: 5,
backgroundColor: "white"
},
})
let {
upperRow
} = style
然后在componentWillReceiveProps中出现类似的内容
componentWillReceiveProps(nextProps) {
if (this.props.coinPrice != nextProps.coinPrice ) {
if (this.props.coinPrice > nextProps.coinPrice) {
console.log("previous value is greater")
//change background color to red
upperRow["backgroundColor"] = "#ffe5e5"
console.log(upperRow)
//We
}
}
}
这是抛出以下错误
您尝试将键
backgroundColor设置为值#ffe5e5在一个本来是不可变的对象上 冷冻。
问题:谁能告诉我这里出了什么问题?
【问题讨论】:
标签: javascript reactjs react-native