Vue3监听标签页变化
import { onMounted } from "vue";
onMounted(() => {
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
console.log("已切换到自己的标签页");
} else {
console.log("已切换到其他标签页");
}
});
});