vue如何监听浏览器刷新事件呢?不仅仅是页面销毁就触发的事件。

在created、mounted 都行啊。

window.addEventListener('beforeunload', e => {

    localStorage.setItem("store",JSON.stringify(this.$store.state))

});

 


posted @ 2019-05-06 19:43  lijjj  阅读(6532)  评论(0编辑  收藏  举报