$nextTick这个方法的意思大概就是数据更新后触发dom节点更新吧,数据多层的时候vue监听不到底层的数据变化,能够使用watch方法深度监听数据的变化,而后使用$nextTick在数据变化后触发dom节点更新,而且数据获取到后要遍历数据放进定义的数组里否则也不会出发dom节点更新vue
$.each(data.resultData,function (index,item) { item.showChild = false; self.tableData.push(item) })
showDetail(item){ console.log(this.tableData) console.log(item) this.$nextTick(function () { item.showChild = !item.showChild }) },
watch:{ tableData:{ handler:function(val,oldVal){ this.tableData = val; }, // 深度观察 deep:true } },