ฉันค่อนข้างใหม่ที่จะตอบสนองและต้องการป้อนการตอบสนอง json ของฉันซึ่งฉันได้รับจาก api ลงในตารางการออกแบบมดที่ว่างเปล่า และฉันไม่รู้ว่าต้องทำอย่างไร
ฉันได้แมป id กับชื่อแล้ว แต่ยังต้องการคอลัมน์อื่นทั้งหมดและอยู่ในรูปแบบตารางของการออกแบบมดด้วย
เจสันตอบกลับ
[
{
"id": 9685,
"name": "Mukesh Rai",
"count of sub": 3,
"count of int": 2,
"count of po": null
},
{
"id": 2085,
"name": "Abhyudaya Singh Panwar",
"count of sub": 1049,
"count of int": 17,
"count of po": 5
},
{
"id": 7087,
"name": "Amit Kumar Sharma",
"count of sub": 363,
"count of int": 68,
"count of po": 10
},
{
"id": 2100,
"name": "Aditya Kumar",
"count of sub": 724,
"count of int": 5,
"count of po": 1
}
]
ไฟล์ส่วนประกอบ
componentDidMount(){
axios.get("http://127.0.0.1:8000/marketer_details/")
.then(response=>{
console.log(response)
this.setState({posts: response.data})
})
.catch(error=> {
console.log(error)
})
}
render() {
const { posts } = this.state
return(
<div>
List of Posts
{
posts.length ?
posts.map(post => <div key = {post.id}>{post.name}</div>) :
null
}
</div>
)
//ต้องการคอลัมน์อื่นๆ ทั้งหมดด้วย
render(){
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
width: '30%',
...this.getColumnSearchProps('name'),
},
{
title: 'Count of Submissions',
dataIndex: 'Count',
key: 'sub',
width: '20%',
...this.getColumnSearchProps('sub'),
},
{
title: 'Count of Interviews',
dataIndex: 'Count',
key: 'int',
...this.getColumnSearchProps('int'),
},
{
title: 'Count of PO',
dataIndex: 'Count',
key: 'po',
...this.getColumnSearchProps('po'),
},
];
return <Table columns={columns} dataSource={this.state.posts} />;
}
}
}
export default App
ฉันไม่เข้าใจว่าการแมปหลายรายการสามารถทำได้อย่างไรกับแต่ละแถวของคอลัมน์
return
สองคำสั่งสำหรับฟังก์ชันนี้ - person Agney   schedule 17.06.2019