上一个文章写了封装全局的方法
然后今天写项目碰到的问题是,我想处理数据,然后更改数据,并在特定的条件之下重新查询,会发现由于then的机制导致一直显示后端发送的数据。
我的解决方法比较粗暴就是在template中给展示数据的地方上v-if和else
声明一个data来解决
具体代码
<div>
<el-table :data="Reprint" @row-click="cellmouseenter" height="650" border stripe v-if="Count_Sprit_Select == '全部'">
<el-table-column align="center" prop="reprintID" label="复刻顺序" width="80" />
<el-table-column align="center" prop="sprit.spritName" label="先祖名字" width="100"/>
<el-table-column align="center" prop="sprit.seasonOrActivity.srName" label="所属季节" width="80" />
<el-table-column align="center" prop="reprintTime" label="复刻时间" width="140" />
</el-table>
<el-table :data="CountReprint" @row-click="cellmouseenter" height="650" border stripe v-else>
<el-table-column align="center" prop="reprintID" label="复刻顺序" width="80" />
<el-table-column align="center" prop="sprit.spritName" label="先祖名字" width="100"/>
<el-table-column align="center" prop="sprit.seasonOrActivity.srName" label="所属季节" width="80" />
<el-table-column align="center" prop="reprintTime" label="复刻时间" width="140" />
</el-table>
</div>
</div>
方法在这里
UserSelect(){
this.CountReprint = []
if(this.Count_Sprit_Select != '全部'){
for(let i = 0;i < this.Reprint.length ; i++){
if (this.Reprint[i].count == this.Count_Sprit_Select){
this.CountReprint.push(this.Reprint[i])
}
}
console.log(this.CountReprint)
}
}
},
大佬轻喷