卡片切换change事件每次变化,都调用this.getList(current),是怎么做到缓存的
来源:5-14 切换选项卡懒加载数据

Jerry卢
2020-11-26
methods: {
//卡片切换触发事件
change(e) {
const { current } = e.detail;
this.getList(current)
this.$emit('change', current);
},
// 获取卡片内容数据
getList(current) {
this.$api.get_list({
name: this.tab[current].name
}).then(res => {
// console.log(res)
const {data} = res;
this.$set(this.listCatchData, current, data)
})
}
}
每次切换卡片的时候,是不是都触发change(e)该事件,那岂不是每次都调用getList(current),那么每次都会发请求后台吧
写回答
1回答
-
慕村6345035
2020-11-28
缓存会存到变量里
00
相似问题