【发布时间】:2019-09-23 03:52:09
【问题描述】:
我有一个对象,稍后将替换为 JSON 响应结构,如下所示,我将其作为道具传递,在子组件中我希望通过“值”映射来呈现数据。
App.js
“data”: {
“title”: {
“text”: “”
},
“subtitle”: {
“text”: “”
},
“renderable”: [
{
“title”: {
“text”: “”
},
“sub_title”: {
“text”: “”
},
“values”: [
{
“id”: “1”,
“title”: {
“text”: “”
},
“subtitle”: {
“text”: “”
},
“price_tag”: {
“text”: “Rs 99"
},
“preselected”: “true”
},
{
“id”: “2",
“title”: {
“text”: “”
},
“sub_title”: {
“text”: “”
},
“price_tag”: {
“text”: “Rs 199”
},
“preselected”: “false”
},
]
}
]
}
class App extends React.Component {
render() {
return (
<React.Fragment>
<Demo options={data} />
</React.Fragment>
)
}
}
我不确定如何在子组件中访问和映射可渲染内部的“值”(目前可渲染内部只有一个对象,但稍后会填充)。
【问题讨论】:
标签: javascript json reactjs