//customTabbar.vue
handleTab(index,url) {
if(this.selectNum !== index) {
wx.redirectTo({url})
}
}
//list.vue
data() {
return {
lists:[]
}
},
methods: {
getLists() {
//ajax
this.lists.push(...res.lists)
}
}
onLoad() {
console.log(this.lists)
this.getLists();
console.log("---------")
},
The project uses a tabbar (customTabbar.vue) of a custom subcomponent, using the redirectTo jump method to delete this page and then jump to another page. As soon as I opened the list.vue page, and then switched back, the data of the list variable of the page became the data of the last request plus the data of this request, and then the switch became the last two times plus this time. I suspect that the variable data of the page was not destroyed.
I changed the getLists method to
getLists() {
//ajax
this.lists=res.lists
}
Just , why use redirect to jump, and the variables on the page will not be destroyed?