How to monitor sessionStroage in vue project

there is a key such as flag in sessionStroage, how to listen for changes in its value. Is there any other way to access this data at regular intervals with a timer

Mar.09,2021

this kind of personal feeling should not be monitored. It is best to manually trigger the update yourself. When you save the flag key, submit the event trigger yourself. Like submitting mutation, in vuex If you have asynchronous operations, use action.


to understand your specific requirements, but the data in sessionStroage will not change on its own initiative. We can probably solve your requirements with this feature, that is, when the logic of your code executes the window.sessionStroage.setItem () method, execute your requirements logic or use vuex to set global calculation properties when When the variable changes, Synchronize stores the value of sessionStroage and performs some operations


without listening. Write subsequent logic when modifying the cache

Menu