关于轮播图定时切换时,页面刷新的问题

需求

要求轮播图第一次加载看板时,页面刷新,后续定时(10s)切换时,不刷新页面

实现

<div>
	<a-button type="link" :class="{activeBtn : activeKey == 0}" @click="handleChange(0)">
		数据运营看板
	</a-button>
	<a-divider
		type="vertical"
	/>
	<a-button type="link" :class="{activeBtn : activeKey == 1}" @click="handleChange(1)">
		数据资产看板
	</a-button>
	<a-divider
		type="vertical"
	/>
	<a-button type="link" :class="{activeBtn : activeKey == 2}" @click="handleChange(2)">
		数据报告看板
	</a-button>
</div>
<a-carousel
	v-if="isRefresh"
	ref="carouselRef"
	:autoplay="true"
	:dots="false"
	:pauseOnHover="true"
	:autoplaySpeed="10000"
	:before-change="beforeChange"
>
	<div class="divDaping">
	     //大屏组件
		<daping class="ifr"></daping1>
	</div>
	<div class="divDaping">
		<daping2 class="ifr" v-if="show1"></daping2>
	</div>
	<div class="divDaping">
		<daping3 class="ifr"  v-if="show2"></daping3>
	</div>
</a-carousel>

data() {
	return {
		activeKey: 0,
		show1: false,
		show2: false,
	}
}

methods: {
	// 判断当前看板是否加载过,没有加载过,则利用v-if进行加载
	initDaping(val) {
		if(val == 1 && this.show1 === false) {
			this.show1 = true;
		}
		if(val == 2 && this.show2 === false) {
			this.show2 = true;
		}
	}, 
	handleChange (val) {
		this.$refs.carouselRef.goTo(val);
		this.activeKey = val;
	},
	// 切换时,初始化看板
	beforeChange (from, to) {
		this.activeKey = to;
		this.initDaping(to);
	}
}
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值