1.新建一个数组
roomArr: ["1", "2", "3", "4","5", "6", "7", "8","9", "10", "11", "12","13", "14", "15"],
number:'',
2.点击抽签,获取随机数,为了有随机的效果,使用了一个定时器
this.timer = setInterval(() => {
this.number = this.roomArr[Math.floor(Math.random() * this.roomArr.length)];
},40)
3.点击暂停,清除定时器,在数组中剔除掉已经选出的数字
clearInterval(this.timer) //清除定时器
console.log(this.number) //这是随机抽取出的数字
this.roomArr = this.roomArr.filter(item => item != this.number) //剔除已经选出的数字,返回新的数组