我有两个按钮,我想将样式保存在异步存储中。目前它们被保存在这样的状态:
state = {
itemOne:styles.button,
itemTwo:styles.button,
}
并且根据值的样式改变
if (value) {
switch (value) {
case "Low":
this.setState({itemOne: styles.styleOne});
break;
case "Moderate":
this.setState({itemOne: styles.styleTwo});
break;
}
}
视图中的按钮看起来像这样
<Button
style={this.state.itemOne}
onPress={() => {
this.popupDialog.show();
}}
>
我正在使用 AsyncStorage 来保存状态,但它出现了这个错误
Warning: Failed prop type: Invalid props.style key `0` supplied to `View`.
Bad object: {
"0": "6",
"1": "9",
"opacity": 1
}
请帮忙!