• 随机抽奖


    随机模板

    <
    template> <div> <div class="box"> <span > &emsp;&emsp;&nbsp;&nbsp; </span> <div class="qs">{{ word }}</div> </div> <div class="btns"> <van-button plain type="primary" class="start" @click="btnFnStart">开始抽奖</van-button> <van-button plain type="primary" class="end" @click="btnFnEnd">暂停</van-button> </div> </div> </template> <script> export default{ data() { return{ word:"奖项", name:["一等奖","二等奖","三等奖","谢谢惠顾","再来一次奖","掌声鼓励一下奖","木有奖","没有奖"], timer:"", jianname:"", }; }, methods:{ btnFnStart(){ clearInterval(this.timer); this.timer = setInterval(this.fn,100); }, fn(){ let num = Math.floor(Math.random()*this.name.length); this.word = this.name[num]; this.jianname = this.name[num]; }, btnFnEnd(){ clearInterval(this.timer); this.name.forEach((item,index)=>{ if(item==this.jianname){ this.name.splice(index,1); } if(this.name.length==0){ this.word = "网络异常"; } }) } }, mounted() { } } </script> <style> * { margin: 0; padding: 0; } h2 { text-align: center; } .box { width: 600px; margin: 50px auto; display: flex; font-size: 25px; line-height: 40px; } .qs { width: 450px; height: 40px; color: red; text-align: center; } .btns { text-align: center; } .btns button { width: 120px; height: 35px; margin: 0 20px; } </style>
  • 相关阅读:
    P2149 [SDOI2009]Elaxia的路线
    电机学第一次课
    大素数区间快判模板
    网络流 最大权闭合子图
    DFS CCPC2017 南宁I题
    稳定婚姻问题模板
    CF438D 线段树 区间求和,区间求膜,单点更新
    对偶图 并查集 BZOJ4423
    BZOJ 1833 数字计数 数位DP
    过一点求对一个直线的垂足
  • 原文地址:https://www.cnblogs.com/dsds/p/15881146.html
Copyright © 2020-2023  润新知