我有一个列表,我需要使用一个按钮进行渲染,该按钮会onPress将值保存到商店中,然后更改为其他路线,但是问题是当我console.log(props)
时我得到{"index":1, "title":"hello world"}
,但是如果我确实console.log(props.index)
一片空白,但没有给我任何价值,这是为什么吗?
答案 0 :(得分:2)
您的错误必须来自其他原因。您所描述的内容没有问题,例如:
var props = {
"index": 1,
"something": "else"
}
console.log(props);
console.log(props.index);
答案 1 :(得分:0)
尝试使用其他道具名称(例如“ myCustomIndex”),我不确定,但是道具中可能不允许使用此关键字。