当前位置:网站首页>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
边栏推荐
- lsf基础命令
- 几行代码搞定RPC服务注册和发现
- Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
- Domestic relatively good OJ platform [easy to understand]
- linux下配置Mysql授权某个用户远程访问,不受ip限制
- Smart trash can (V) - light up OLED
- IDEA2021.1 安装教程
- Believe in yourself and finish the JVM interview this time
- 超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业
- TCP congestion control details | 2 background
猜你喜欢
Eye of depth (III) -- determinant of matrix
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
[fluent] dart data type map type (create map set | initialize map set | traverse map set)
ThreadLocal
Baobab's gem IPO was terminated: Tang Guangyu once planned to raise 1.8 billion to control 47% of the equity
Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品
[cloud native] briefly talk about the understanding of flume, a massive data collection component
【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦
TCP拥塞控制详解 | 2. 背景
随机推荐
对接保时捷及3PL EDI案例
Sword finger offer 22 The penultimate node in the linked list
Does digicert SSL certificate support Chinese domain name application?
详细介绍scrollIntoView()方法属性
Shutter: action feedback
linux安装postgresql + patroni 集群问题
[leetcode] 14. Préfixe public le plus long
Tech talk activity preview | building intelligent visual products based on Amazon kVs
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
P6774 [NOI2020] 时代的眼泪(分块)
The macrogenome microbiome knowledge you want is all here (2022.7)
Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
class和getClass()的区别
Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
Qwebengineview crash and alternatives
VMware install win10 image
海思Hi3798MV100机顶盒芯片介绍[通俗易懂]
电脑自带软件使图片底色变为透明(抠图白底)
13、Darknet YOLO3
Timing / counter of 32 and 51 single chip microcomputer