当前位置:网站首页>visibilitychange – 指定标签页可见时,刷新页面数据
visibilitychange – 指定标签页可见时,刷新页面数据
2022-07-02 14:42:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
三个知识点:
一通过监听浏览器页面可见性改变(visibilitychange)事件,来判断标签页是否可见
二配置路由的meta,来判断是否是指定的标签页
三调用其它模块的actions,刷新数据
router.js
routes: [
{
path: "/",
redirect: "index"
}, {
path: "/index",
name: "index",
meta: { dataRefresh: true },
component: Index
}, {
path: "check",
name: "check",
meta: { dataRefresh: false },
component: () => import("@/views/check/check.vue")
}
]
main.js
new Vue({
router,
store,
render: h => h(App),
created() {
window.document.addEventListener('visibilitychange', () => {
if(window.document.visibilityState === 'visible' && this.$router.history.current) {
let currentRouter = this.$router.history.current
if(currentRouter.meta.dataRefresh) {
// 调用首页模块的actions,刷新列表数据
store.dispatch('home/fetchListData')
}
}
})
}
}).$mount('#app');
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/148022.html原文链接:https://javaforall.cn
边栏推荐
- Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))
- 什么是泛型?- 泛型入门篇
- P6774 [NOI2020] 时代的眼泪(分块)
- The computer comes with software to make the background color of the picture transparent (matting white background)
- uboot的作用和功能
- Shutter: action feedback
- jsp 和 servlet 有什么区别?
- Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan
- 易语言abcd排序
- C语言中sprintf()函数的用法
猜你喜欢
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
Changwan group rushed to Hong Kong stocks: the annual revenue was 289million, and Liu Hui had 53.46% voting rights
Interpretation of key parameters in MOSFET device manual
871. Minimum refueling times
Error when uploading code to remote warehouse: remote origin already exists
上传代码到远程仓库报错error: remote origin already exists.
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
使用知行之桥的API端口,提供资源供合作伙伴访问
体验居家办公完成项目有感 | 社区征文
Blog theme "text" summer fresh Special Edition
随机推荐
Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
[cloud native] briefly talk about the understanding of flume, a massive data collection component
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
易语言abcd排序
电脑自带软件使图片底色变为透明(抠图白底)
VMware install win10 image
Usage of sprintf() function in C language
剑指 Offer 27. 二叉树的镜像
MOSFET器件手册关键参数解读
Flutter: 动作反馈
福元医药上交所上市:市值105亿 胡柏藩身价超40亿
Digital IC hand tearing code -- voting device
远程办公对我们的各方面影响心得 | 社区征文
Error when uploading code to remote warehouse: remote origin already exists
linux下配置Mysql授权某个用户远程访问,不受ip限制
class和getClass()的区别
P6774 [noi2020] tears in the era (block)
Eye of depth (III) -- determinant of matrix
配置基于接口的ARP表项限制和端口安全(限制用户私自接入傻瓜交换机或非法主机接入)
Sword finger offer 26 Substructure of tree