SoFunction
Updated on 2025-04-03

Solve the issue of vue keep-alive data update

Use <keep-alive> to include <router-view> in the project to implement page caching, speed up page loading,

At the same time, this method brings some disadvantages, please see the following explanation of the master:

***********************************

When keep-alive is introduced, the page enters for the first time, the triggering order of the hook is created-> mounted-> activated, and the deactivated is triggered when exiting.

When entering again (forward or backward), only activated is triggered.

***********************************

This brings up a problem. Previously, using mounted in the project to get data when the page is loaded. The method will no longer take effect after using <keep-alive>.

According to the above explanation, just replace mounted with activated.

The above article solves the problem of vue keep-alive data update is all the content I share with you. I hope it can give you a reference and I hope you can support me more.