当前位置:网站首页>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
边栏推荐
- GeoServer:发布PostGIS数据源
- Sword finger offer 27 Image of binary tree
- How openharmony starts FA of remote devices
- Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
- Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
- Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...
- dstat使用[通俗易懂]
- 你想要的宏基因组-微生物组知识全在这(2022.7)
- Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
- System Verilog implements priority arbiter
猜你喜欢
Connect Porsche and 3PL EDI cases
Geoserver: publishing PostGIS data sources
Linux Installation PostgreSQL + Patroni cluster problem
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
电脑自带软件使图片底色变为透明(抠图白底)
Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
Timing / counter of 32 and 51 single chip microcomputer
宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
Use the API port of the bridge of knowledge and action to provide resources for partners to access
Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan
随机推荐
你想要的宏基因组-微生物组知识全在这(2022.7)
相信自己,这次一把搞定JVM面试
Error when uploading code to remote warehouse: remote origin already exists
How to quickly distinguish controlled components from uncontrolled components?
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
Easy language ABCD sort
体验居家办公完成项目有感 | 社区征文
Talk about an experience of job hopping and being rejected
QWebEngineView崩溃及替代方案
使用知行之桥的API端口,提供资源供合作伙伴访问
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
[fluent] dart data type map type (create map set | initialize map set | traverse map set)
P6774 [NOI2020] 时代的眼泪(分块)
Green bamboo biological sprint Hong Kong stocks: loss of more than 500million during the year, tiger medicine and Beijing Yizhuang are shareholders
The impact of telecommuting on all aspects of our experience | community essay solicitation
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
有赞和腾讯云、阿里云一同摘得“中国企业云科技服务商50强”[通俗易懂]
13、Darknet YOLO3
IP地址转换地址段
js删除字符串中的子串