Open Mardanjan opened 4 years ago
普通的watch属性不能监听对象内部属性的变化,需要加depp:true, 也可以单独监听对象里的某个属性,, https://blog.csdn.net/qq_33878858/article/details/93886574 这个文章可以
watch: { item:{ handler(val){ console.log('val',val) if (this.item.product_detail) { if (this.item.product_detail.length > 2) { this.head_item = this.item.product_detail.slice(0,2) this.body_item = this.item.product_detail.slice(2) this.isShowMore = true return } else if (this.item.product_detail.length <= 2) { this.head_item = this.item.product_detail.slice(0,2) this.isShowMore = false } }else if (!this.item.product_detail) { this.isShowMore = false this.head_item = this.item.product_detail } }, deep:true } },
普通的watch属性不能监听对象内部属性的变化,需要加depp:true, 也可以单独监听对象里的某个属性,, https://blog.csdn.net/qq_33878858/article/details/93886574 这个文章可以