当前位置:网站首页>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
边栏推荐
- 【Leetcode】13. 罗马数字转整数
- Sword finger offer 26 Substructure of tree
- 二、mock平台的扩展
- Sword finger offer 22 The penultimate node in the linked list
- Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))
- 上传代码到远程仓库报错error: remote origin already exists.
- QWebEngineView崩溃及替代方案
- Method of C language self defining function
- Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan
- The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
猜你喜欢

【Leetcode】14. Longest Common Prefix

Notice on holding a salon for young editors of scientific and Technological Journals -- the abilities and promotion strategies that young editors should have in the new era

Experience home office, feel the completion of the project | community essay solicitation

How to transfer business data with BorgWarner through EDI?

Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品

剑指 Offer 26. 树的子结构

易语言abcd排序

Eth data set download and related problems

Ap和F107数据来源及处理

Sword finger offer 26 Substructure of tree
随机推荐
IPtables中SNAT、DNAT和MASQUERADE的含义
OpenHarmony如何启动远程设备的FA
Eye of depth (III) -- determinant of matrix
LSF basic command
二、mock平台的扩展
Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
[leetcode] 14. Préfixe public le plus long
七张图,学会做有价值的经营分析
DGraph: 大规模动态图数据集
Sword finger offer 27 Image of binary tree
Chapter 3 of hands on deep learning - (1) linear regression is realized from scratch_ Learning thinking and exercise answers
uboot的作用和功能
Method of C language self defining function
Youzan won the "top 50 Chinese enterprise cloud technology service providers" together with Tencent cloud and Alibaba cloud [easy to understand]
Talk about an experience of job hopping and being rejected
871. 最低加油次数
Xiaopeng P7 had an accident on rainy days, and the airbag did not pop up. Official response: the impact strength did not meet the ejection requirements
TCP拥塞控制详解 | 2. 背景
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
一文看懂:数据指标体系的4大类型