There is a problem in the project: click the list page or some filter criteria to search the list, click to view the details of a certain item, and return the original filter criteria.
- Add to meta when adding routes
keepAlive: true,
2. Set a variable in data that controls whether to refreshcreated
Set this variable to true
data(){
return{
isCreated: false}},created(){
this.isCreated = true
}
Copy the code
reset
Is a function of the reset condition,query
For the function that loads the list, refresh the list (with arguments) when these specific names are returned
beforeRouteEnter(to, from, next) {
next(vm= > {
if (
from.name ! ="createContract" &&
from.name ! ="createPerContract" &&
!vm.isCreated
) {
vm.reset();
} else if((from.name == "createContract" || from.name == "createPerContract") &&
!vm.isCreated
) {
console.log("vm.pageJson.page :>> ", vm.pageJson.page); vm.query(vm.pageJson.page); }}); },beforeRouteLeave(to, from, next) {
this.isCreated = false;
next();
}
Copy the code