When returning to this page from another page, clear the checkbox check status?

clipboard.png
use the check box data stored by localStorage. The effect you want to achieve is to save the selected check box only when the current page and the order details page that the current page jumps to, but when you click on another page and return to this page, what can you use to uncheck all the check boxes? Which lifecycle hook?

Oct.08,2021

the problem is simple. Here is the technical solution for the vuejs technology stack:

  1. it is recommended that you use a vuex state machine to save checkbox data instead of localStorage,. Why? Because it involves the data rendering relationship between different page components!
  2. when you go to other pages, that is, when you judge with the vue-router hook, the non-current page and the non-current page jump to the order details page, clear the data in the state machine vuex. When you return to this page, you will find that the data obtained from vuex is gone.
  3. it's the same thing if you have to use localStorage, it's all in multiple components, that is to say, you can get data between different components.

only technical solution explanation is provided, but the specific code is not provided. Thank you for adopting.

Menu