Vue 随机分配的打扫卫生H5 :打扫让我快乐
2024-08-27 07:46:02
情况是这样子的,每周四是我们小组打扫卫生,一共有四件活,7个人分配。
活分别是 : 扫地 拖地 倒垃圾 擦桌子
人分别是: '军', '春', '龙', '东', '贤', '磊','卿'
但是,每次打扫卫生都有人不动手,每次都是我拖地。。所以跟小组长提出,随机分配、
#需求:
每个人随机选择自己的工作
按数组排列 7个人
打乱顺序 显示到页面即可
有请假需要 点一下变成问号 不影响随机排序
#需要的方法
vue
随机打乱数组
循环20次 跑马灯的感觉
#美化样式
背景,标题,
目前页面初始和点击后的型:
页面css:
* {
margin:;
padding:;
text-shadow: 0px 0px 12px rgba(150, 122, 122, 0.8);
}
#app{
width: 100vw;
height: 100vh;
background-size: cover;
}
body{
background:
radial-gradient(black 15%, transparent 16%) 0 0,
radial-gradient(black 15%, transparent 16%) 8px 8px,
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px,
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;
background-color:#282828;
background-size:16px 16px;
} span {
display: inline-block;
width: 40px;
height: 30px;
border: 1px solid #000;
text-align: center;
background-color: #cc2323;
line-height: 30px;
color: #fff;
border-radius: 3px;
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.8);
overflow: hidden;
} ul,
li {
list-style: none; } ul {
width: 80%;
display: flex;
flex-direction: row;
align-self: center;
justify-content: space-between;
margin: 0 10%;
padding: 25px 0 30px; } h2 {
text-align: center;
font-weight:;
padding: 50px 0;
color: #eeeeee;
letter-spacing: 8px;
} p {
width: 80%;
margin: 0 10%;
font: 16px sans-serif;
color: #eeeeee;
} button {
border: none;
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
color: #ffffff;
line-height: 2.55555556;
border-radius: 3px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
overflow: hidden;
background-color: #cc2323;
margin: 50px auto;
box-shadow: 2px 2px 19px rgb(0, 0, 0);
} .thing {
display: flex;
width: 80%;
margin: 10px 10%;
padding: 20px 0;
flex-direction: row;
justify-content: space-around;
align-items: center;
border-radius: 3px;
background-color: #cc2323;
color: wheat;
box-shadow: 1px 1px 12px rgb(0, 0, 0);
opacity: 0.9;
} .b-shadow {
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.8);
}
页面结构:
<div id="app">
<img style="width: 100vw;height: auto" src="header.png" alt="">
<p>
点击男嘉宾即可请假:
</p>
<ul>
<li v-for="(item,index) in person" @click="change(index)">
<span>{{item}}</span>
</li>
</ul>
<div class="thing">
昆仑拖地把:<span>{{randomPerson[0]}}</span>+<span>{{randomPerson[1]}}</span> </div>
<div class="thing">
少林扫地僧:<span>{{randomPerson[2]}}</span>+<span>{{randomPerson[3]}}</span>
</div>
<div class="thing">
华山垃圾车:<span>{{randomPerson[4]}}</span>+<span>{{randomPerson[5]}}</span>
</div>
<div class="thing">
武当擦桌子:<span>{{randomPerson[6]}}</span>
</div> <button class="" @click="alert" value="">开始摇滚</button>
</div>
JavaScript:
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
person: [
'军', '春', '龙', '东', '贤', '磊','卿'
],
randomPerson: ['?', '?', '?', '?', '?', '?','?'],
time: 20 //跑马跳动20次
},
methods: {
alert: function () {
this.randomPerson = this.person;
let arr = this.randomPerson;
let time = this.time; function shuffle(arr) {//数组随机方法
arr.sort(function () {
return Math.random() - 0.5;
});
} for (let i = 0; i < time; i++) {
setTimeout(function () {
shuffle(arr);//执行数组随机
}, i * 100);
this.randomPerson = arr;
} },
change: function (index) {
console.log(index);
this.person.splice(index, 1, '?');//请假的操作
}
} })
</script>
最新文章
- HTML 通知公告练习
- Linux USB摄像头驱动【转】
- apache日志轮转
- string.Split函数
- bzoj1008: [HNOI2008]越狱
- ERROR: HHH000388: Unsuccessful: create table
- SQL学习之学会使用子查询
- [NOIP2001提高组]CODEVS1014 Car的旅行路线(最短路)
- tastypie Django REST framework
- mysql sql语句大全(转载)
- app调用支付宝支付 笔记
- SQL模糊查询条件的四种匹配模式
- 分布式监控系统Zabbix3.2跳坑指南
- 【TCP/IP 协议】 TCP/IP 基础
- cannot be run because the QueueReader subsystem failed to load
- Sublime Text3 调色板 ColorPicker插件安装及快捷键
- jquery 获取name一样的值
- Perl子程序引用和匿名子程序
- Python中类的定义及使用
- Centos下启动和关闭MySQL
热门文章
- Java中快捷键
- 开源litemall学习
- Python爬虫案例-获取最新的中国行政区域划分
- SVM小白教程(2):拉格朗日对偶
- 2018-2019-2 20165325 《网络对抗技术》 Exp5:MSF基础应用
- lua简单入门
- Asp.Net Core配置Swagger
- ORACLE根据两个表都含有的字段条件来判断两个表连接后有没有数据
- python2 使用pip安装psycopg2出现错误:Command ";python setup.py egg_info"; failed with error code 1 in /tmp/pip-install-mvzdNj/psycopg2/
- SQL语句50题