How does vue listen for browser refresh events? It's not just an event triggered by the destruction of a page.

the current requirement is that some component records a sessionStorage status when the page is refreshed, but not under the condition of a route jump.
so neither destroyed nor beforeDestroy is suitable.
the onbeforeunload method searched on the Internet is not clear where to use it. When you try to call it in beforeDestroy, it does not trigger the method. What hook function should be used in
Vue to execute the onbeforeunload method? Or what is a better way for Vue to listen for browser refresh events?

Apr.09,2021

created or mounted is fine.

window.addEventListener('beforeunload', e => {
    localStorage.setItem('abcde', 'asdas');
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a76d-41258.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a76d-41258.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?