mounted() {
	// 添加监听事件
    document.addEventListener("visibilitychange", this.handleVisiable);
},
methods: {
	handleVisiable: function (e) {
		if (e.target.visibilityState == "visible") {
			console.log("回到当前tab标签");
		} else {
			console.log("离开当前tab标签");
		}
    },
},
beforeDestroy() {
	document.removeEventListener('visibilitychange', this.handleVisiable)
},
Logo

前往低代码交流专区

更多推荐