前不久我准备用静态搜索,发现怎么赋值都不能把后台的东西完全传入,询问过后发现是因为没有进行深度拷贝;
sou() {
this.$axios.get('/bta/category/get/category').then(res => {
res.datas.forEach(v => {
v.show = false;
});
console.log(res.datas);
this.accordion = res.datas;
this.newaccordion = JSON.parse(JSON.stringify(this.accordion));
});
},
/*查找*/
chazao() {
this.newaccordion = JSON.parse(JSON.stringify(this.accordion));
if (!this.chazaokejian) {
return;
}
this.newaccordion = this.newaccordion.map(item => {
item.wareModel = item.wareModel.filter(j => {
return j.wareName.indexOf(this.chazaokejian) !== -1 || j.author.indexOf(this.chazaokejian) !== -1;/*查询课件名与作者 */
});
return item;
});
console.log(this.accordion);