如何读取嵌套对象React Redux的属性?

时间:2019-02-08 14:56:42

标签: reactjs redux

请帮助我获取嵌入式对象React redux的属性:

{
  "id":1
  "name":"Jonh"
  "pets": {
    "namepets": {
      "String":"King-kong"
      "Valid": true
    },
    "age": {
      "String":"11",
      "Valid": true
    }
  }
}

如果我写console.log(this.props.user.pets),则在控制台中看到该对象,但是我写了console.log(this.props.user.pets.namepets)

我遇到此错误:

  

TypeError:无法读取未定义的属性“ namepets”

如何获得该值?

1 个答案:

答案 0 :(得分:0)

如果要获取此对象:

SELECT [columns] 
FROM [Table B] 
INNER JOIN [Table A] 
    ON A.RecordID = B.RecordID 
    AND B.RecordID = 1; 

检查{"id":1,"name":"Jonh","pets":{"namepets": {"String":"King-kong","Valid": true}, "age": {"String":"11","Valid": true}}} 后,其完整属性为:

this.props.user.pets

(不是很漂亮)