rand(min, max) {
return Math.ceil(Math.random() * (max - min + 1)) + min + 1;
},
handleMe() {
this.times=this.times+1 //times需要在定义在全局,我用vue
const n = this.rand(1, 100);
if (n <=1||this.times==11) {
this.times=0
alert("恭喜中奖劳斯莱斯小汽车一台"+n+"次数"+this.times);
} else {
alert("再接再厉"+n+"次数"+this.times);
}
},
利用random实现简单抽奖
最新推荐文章于 2024-11-28 19:56:47 发布