页面销毁时关闭sseSource

This commit is contained in:
panlinlin 2021-04-06 15:13:23 +08:00
parent 157216a4da
commit 3168b90520

View File

@ -71,6 +71,10 @@ export default {
}, },
destroyed() { destroyed() {
window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e)) window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e))
this.sseSource.removeEventListener('open', null);
this.sseSource.removeEventListener('message', null);
this.sseSource.removeEventListener('error', null);
this.sseSource.close();
// window.removeEventListener('unload', e => this.unloadHandler(e)) // window.removeEventListener('unload', e => this.unloadHandler(e))
}, },
} }