当前位置:网站首页>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
边栏推荐
猜你喜欢

Seven charts, learn to do valuable business analysis

QWebEngineView崩溃及替代方案

剑指 Offer 27. 二叉树的镜像

A few lines of code to complete RPC service registration and discovery

What if the default browser cannot be set?

Chapter 3 of hands on deep learning - (1) linear regression is realized from scratch_ Learning thinking and exercise answers

宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权

关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...

871. 最低加油次数

Sword finger offer 27 Image of binary tree
随机推荐
What is generics- Introduction to generics
Sword finger offer 24 Reverse linked list
默认浏览器设置不了怎么办?
class和getClass()的区别
dstat使用[通俗易懂]
GeoServer:发布PostGIS数据源
Use the API port of the bridge of knowledge and action to provide resources for partners to access
2022 interview questions
Sword finger offer 27 Image of binary tree
A few lines of code to complete RPC service registration and discovery
【Leetcode】14. 最长公共前缀
Exploration of mobile application performance tools
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
LeetCode:1380. Lucky number in matrix -- simple
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
远程办公对我们的各方面影响心得 | 社区征文
Flutter: 动作反馈
One year is worth ten years
Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
How to transfer business data with BorgWarner through EDI?