需要注意该窗口是打开还是关闭... 它在使用SetInterval并提前关闭窗口时有效,但是,如何检测何时没有SetInterval真正关闭并触发它...
<template>
<button class="btn btn-info" @click="OpenTask('http://google.com')">Open window</button>
</template>
<script>
export default {
data() {
return {
window: null,
task:[],
}
},
mounted() {
},
beforeDestroy() {
},
watch: {
},
methods: {
OpenTask(url){
var that = this;
Vue.prototype.surf = window.open(url,'_blank');
this.window = this.surf.closed;
setInterval(function e () {
console.log(that.surf.closed);
}, 7000);
if(that.surf.closed)){
console.log(that.surf.closed);
this.window = this.surf.closed;
}}
},
}
}
</script>
实际上没有检测到何时关闭窗口...如何制作?