created () {
this.getData()
},
watch: {
$route (to, from) {
// 执行ajax请求,但只希望在进入时请求,离开时不希望进行请求。
this.getData()
}
}
The current situation is that the router makes requests when entering or leaving. How to solve unnecessary requests?
Thanks you in advance.
beforeRouteEnter is better?
Use routing hook function
or component hook function