我有一个关于呈现对象中属性值的问题。这是我的对象,它是JSON的格式
Object {
"C": { more nest JSON },
"B": "b"
"A": { more nest JSON },
}我将该对象保存在状态中,如下所示:
this.setState({
Object: Ojbect
})我想按照A,B,C顺序呈现JSON值,但是它们都不能呈现,并且没有语法错误。知道怎么修吗?这就是我写的
render(){
return(
//also try : <p> A: <pre>{JSON.Stringify(this.state.Obejct["A"], null,2)} <pre> <p>
<p> A: <pre>{JSON.Stringify(this.state.Obejct.A, null,2)} <pre> <p>
<p> B: <pre>{JSON.Stringify(this.state.Obejct.B, null,2)} <pre> <p>
<p> C: <pre>{JSON.Stringify(this.state.Obejct.C, null,2)} <pre> <p>
)
}发布于 2021-03-22 23:38:28
我一个人回答这个问题。最后,我发现我们不能在呈现中直接呈现对象。因此,有三种解决方案:
。
https://stackoverflow.com/questions/66716569
复制相似问题