<template>
<div>
<div><button @click="changeTitle">按钮</button></div>
<p>{{ title }}</p>
</div>
</template>
<script>
export default {
data() {
return {
title: '',
isReceive: true
};
},
methods: {
changeTitle() {
let time = 0;
this.title = document.title;
console.log(document.title);
setInterval(function () {
time++;
console.log(time);
if (time % 2 == 0 && document.hidden) {
console.log(0);
document.title = '【你有新消息】';
} else {
console.log(1);
document.title = '【 】';
}
}, 500);
}
}
};
</script>
<style>
</style>
08-13
12-24
1万+