Created and mounted are not executed after the Vue route enters the page for the second time.

Problem description : Every time the page is opened, the data needs to be reloaded. For example, if the data is updated on the general management page, then the latest data needs to be loaded when the details page is opened for the second time. The data loading method is written in the mounted method, but it is not executed.

Problem analysis : Because created and mounted in routing will be cached by default, unless configured in router.js: keepAlive : false; this turns off the routing cache of this page; true means on, false means off.

Problem solution :

1. Place the method to be processed in the beforeCreate function


beforeCreate() {
    // 执行函数
this.$router.push("/mjxt/entranceguard"); // 直接跳转门禁页面
}


2. Change the configuration items in router.js of the route

meta: {
  keepAlive: false
}

 

 

 

Guess you like

Origin blog.csdn.net/m0_61601708/article/details/130622579