tab 增加了计时器,可自动切换。
export default {
name: "",
components: { },
data() {
return {
activeIndex: 0,
timer: null // 定时器
}
},
mounted() {
this.timer = setInterval(() => {
this.activeIndex+= 1;
if(this.activeIndex>4){
this.activeIndex= 0; // 循环
}
//这里放当前数据
}, 3000);
},
// 销毁定时器
destroyed () {
clearInterval(this.timer);
this.timer = null;
},
}