const person ={ name:'Jake', email:'jake@example.com', phone:'555-555-5555'}// With destructuring(使用解构)const{ name, email, phone }= person
// Without destructuring(没有解构)const name = person.name
const email = person.email
const phone = person.phone
从 this 解构
data(){return{
endpoint:'example.com/api',}},
methods:{postForm(){// this is just an example method we can call in submitForm }submitForm(){// Without destructuring(没有解构)const endpoint =this.endpoint
const postForm =this.postForm
// With destructuring(使用解构)const{ endpoint, postForm }=this}}
作用域插槽
<!-- Without Destructuring(没有解构) --><User v-slot="slotProps"><div>Name:{{ slotProps.name }}</div><div>Email:{{ slotProps.email }}</div></User><!-- With Destructuring(使用解构) --><User v-slot="{ name, email }"><div>Name:{{ name }}</div><div>Email:{{ email }}</div></User>