vue监听页面的刷新状态

listenPage() {
        window.onbeforeunload = function (e) {
          e = e || window.event;
          if (e) {
            e.returnValue = '关闭提示';
          }
          return '关闭提示';
        };
 }

在mounted中调用即可,当按下F5刷新时会弹出提示窗口。

posted @ 2020-03-27 16:42  kitterKing  阅读(13769)  评论(0)    收藏  举报