代码如下:
<template>
<el-main>
<i class="el-icon-caret-right" id="a1"></i>
<i class="el-icon-caret-right" id="a2"></i>
<i class="el-icon-caret-right" id="a3"></i>
<i class="el-icon-caret-right" id="a4"></i>
<i class="el-icon-caret-right" id="a5"></i>
<i class="el-icon-caret-right" id="a6"></i>
</el-main>
</template>
<script>
export default {
data() {
return {
single:1,
count:0,
list:['a1','a2','a3','a4','a5','a6']
}
},
mounted(){
this.move()
},
methods: {
move(){
var test = setInterval(() => {
let a = document.getElementById(this.list[this.count])
if(this.single%2!=0){
a.style.color = "white"
}
if(this.single%2==0){
a.style.color = "black"
}
this.count = this.count+1
if(this.count==6){
this.count=0
this.single=this.single+1
}
if(this.single==3){
clearInterval(test)
}
}, 200);
}
}
}
</script>