Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="//cdn.bootcss.com/vue/2.3.4/vue.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
#app ul li {
width: 100px;
height: 100px;
box-sizing: border-box;
background: #ccc;
float: left;
}
#app ul li.active {
border: 3px solid red;
}
</style>
</head>
<body>
<p id="app">
<ul>
<li v-for="(item, index) of items" :class="{active: index == actvieIndex}">{{ item.name }}</li>
</ul>
</p>
<script>
var app = new Vue({
el: '#app',
data () {
return {
actvieIndex: 0,
items: [
{name: '1'},
{name: '2'},
{name: '3'},
{name: '4'},
{name: '5'}, // 这些都假设是一些用户名字
{name: '6'},
{name: '7'},
{name: '8'},
{name: '9'},
{name: '10'},
{name: '11'},
{name: '12'},
{name: '13'},
{name: '14'},
{name: '15'},
{name: '16'},
{name: '17'},
]
}
},
mounted () {
setInterval(() => {
this.actvieIndex++;
if(this.actvieIndex >= this.items.length ) this.actvieIndex = 0;
}, 50);
}
})
</script>
</body>
</html>
For example, the display should stop after 10 seconds. When it is almost 10 seconds, it should stop slowly. This way users will have that sense of excitement.
I believe everyone has played roulette, just like that. But don't know how to do it.
I simply made a demo.
Then your timer can be executed in two 5s, the first 5s is fast and the last 5s is slow.