当前位置:网站首页>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
边栏推荐
- Deep learning image data automatic annotation [easy to understand]
- lsf基础命令
- 国内比较好的OJ平台[通俗易懂]
- Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
- 深度学习图像数据自动标注[通俗易懂]
- Qstype implementation of self drawing interface project practice (II)
- Understand one article: four types of data index system
- Chapter 3 of hands on deep learning - (1) linear regression is realized from scratch_ Learning thinking and exercise answers
- Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
- 2022 interview questions
猜你喜欢

Use of openpose

Amazon cloud technology community builder application window opens

ETH数据集下载及相关问题

一文看懂:数据指标体系的4大类型

Understand one article: four types of data index system

【Leetcode】13. 罗马数字转整数

伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO

Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers

Use the API port of the bridge of knowledge and action to provide resources for partners to access

How to transfer business data with BorgWarner through EDI?
随机推荐
Qstype implementation of self drawing interface project practice (II)
远程办公对我们的各方面影响心得 | 社区征文
酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
Sword finger offer 27 Image of binary tree
体验居家办公完成项目有感 | 社区征文
IP address translation address segment
linux安装postgresql + patroni 集群问题
[leetcode] 14. Préfixe public le plus long
入行数字IC验证后会做些什么?
Easy language ABCD sort
TCP congestion control details | 2 background
Use of openpose
Youzan won the "top 50 Chinese enterprise cloud technology service providers" together with Tencent cloud and Alibaba cloud [easy to understand]
剑指 Offer 24. 反转链表
VMware install win10 image
Role and function of uboot
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
Seven charts, learn to do valuable business analysis
Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
Eye of depth (III) -- determinant of matrix