一、
data() {
return {
product: {
id: 1,
title: "Nike Air Zoom Pegasus 38",
product_image: "/resources/products/01.jpeg",
shown: "White/Pure Platinum/Midnight Navy/Wolf Grey",
price: 120,
},
}
}
const { id, title } = this.product;
二、
const numbers = [1,2,3];
const [head,...tail] = numbers;
console.log(head) //1
console.log(tail)//[2,3]
三、
products: {
1: {
title: "Nike Air Zoom Pegasus 38",
price: 120,
},
2: {
title: "Nike Air Zoom Alphafly NEXT%",
price: 275,
},
3: {
title: "Nike Zoom Fly 4",
price: 89.0,
},
},
const {2:{title:gettitle}} = this.products; //可改名
const {2:{title,price}} = this.products;
console.log(title,price)