【发布时间】:2020-08-04 13:05:38
【问题描述】:
const book1 = this.state.books[0]; //giving one book
console.log(book1); //output->{id: 1, bookname: "Physics", price: 600, author: "ABC", pages: 567, …}
const {id,bookname,price,author,pages,category} = {book1};
console.log(price); //output->undefined
我已经尝试了很多东西。如何获得特定财产的价值? 这是 JSON 文件:
[
{
"id": 1,
"bookname": "Physics",
"price": 600,
"author": "ABC",
"pages": 567,
"category" : "Science"
}
]
【问题讨论】:
-
下次请根据(stackoverflow.com/conduct)提供问题的正确样式格式
标签: json reactjs output undefined state