当前位置:网站首页>Visibilitychange – refresh the page data when the specified tab is visible
Visibilitychange – refresh the page data when the specified tab is visible
2022-07-02 17:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Three knowledge points :
One is to change the visibility of the browser page by listening (visibilitychange) event , To judge label Whether the page is visible
II. Configure routing meta, To determine whether it is the specified tab
3. Calling other modules actions, Refresh data
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) {
// Calling the homepage module actions, Refresh list data
store.dispatch('home/fetchListData')
}
}
})
}
}).$mount('#app');
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148022.html Link to the original text :https://javaforall.cn
边栏推荐
- Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
- Error when uploading code to remote warehouse: remote origin already exists
- IPtables中SNAT、DNAT和MASQUERADE的含义
- Connect Porsche and 3PL EDI cases
- PhD Debate-11 预告 | 回顾与展望神经网络的后门攻击与防御
- The impact of telecommuting on all aspects of our experience | community essay solicitation
- Un an à dix ans
- traceroute命令讲解
- Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
- 13、Darknet YOLO3
猜你喜欢
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))
剑指 Offer 25. 合并两个排序的链表
[leetcode] 14. Préfixe public le plus long
使用知行之桥的API端口,提供资源供合作伙伴访问
綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東
Seven charts, learn to do valuable business analysis
【Leetcode】13. 罗马数字转整数
寒门再出贵子:江西穷县考出了省状元,做对了什么?
随机推荐
Chapter 3 of hands on deep learning - (1) linear regression is realized from scratch_ Learning thinking and exercise answers
linux安装postgresql + patroni 集群问题
剑指 Offer 24. 反转链表
LeetCode:1380. Lucky number in matrix -- simple
Believe in yourself and finish the JVM interview this time
一文看懂:数据指标体系的4大类型
TCP拥塞控制详解 | 2. 背景
R and rstudio download and installation tutorial (super detailed)
Green bamboo biological sprint Hong Kong stocks: loss of more than 500million during the year, tiger medicine and Beijing Yizhuang are shareholders
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
IPtables中SNAT、DNAT和MASQUERADE的含义
书包网小说多线程爬虫[通俗易懂]
Baobab's gem IPO was terminated: Tang Guangyu once planned to raise 1.8 billion to control 47% of the equity
智能垃圾桶(五)——点亮OLED
Sword finger offer 22 The penultimate node in the linked list
In MySQL and Oracle, the boundary and range of between and precautions when querying the date
Sword finger offer 25 Merge two sorted linked lists
亚马逊云科技 Community Builder 申请窗口开启
二、mock平台的扩展
Exploration of mobile application performance tools