信仰圣光吧
随机抽,但抽中的值不传到后台,最后显示的值从后台取。
<template>
<div>
<div class="box">
<div>{{screen}}</div>
<button @click="btn">点击开始</button>
</div>
</div>
</template>
<script>
export default {
data () {
return {
screen: '',
timer: '',
aList: ['1', '2', '3', '4', '5'],
sureDate: '我我我我',
}
},
methods: {
btn: function () {
if (this.timer) {
clearInterval(this.timer);
this.timer = '';
this.screen = this.sureDate;
} else {
this.timer = setInterval(()=>{
let len = this.aList.length;
let radom = Math.random()*len;
let integerNum = Math.floor(radom);
this.screen = this.aList[integerNum];
},50)
}
},
}