在向symfony API平台发出请求后,他们会返回我的属性,如下所示:
@context: "/api/contexts/User"
@id: "/api/users"
@type: "hydra:Collection"
hydra:member: Array(2)
0: "Création de compte enregistrée."
1: {@id: "/api/users/3", @type: "User", id: 3, email: "*******@outlook.com", firstname: "******", …}
length: 2
__proto__: Array(0)
hydra:totalItems: 2
__proto__: Object
但是我无法从react JavaScript访问hydra: member
属性。
您可以使用以下符号访问对象属性:object['hydra:member']
。与@id
、@type
相同。