<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.boss {
width: 400px;
height: 100%;
margin: 0 auto;
}
.box1 {
width: 100%;
height: 80px;
text-align: center;
line-height: 80px;
color: rgb(88, 192, 142);
font-size: 40px;
}
.box2 {
width: 100%;
/* height: 100%; */
background-color: #fff;
box-shadow: 0px 0px 5px 0px black;
margin: 20px 0;
padding: 0 10px;
box-sizing: border-box;
overflow: hidden;
}
.box3 {
width: 370px;
height: 60px;
border: 3px solid rgb(88, 161, 192);
margin: 0 auto;
margin-top: 10px;
border-radius: 10px;
}
.box3 input {
width: 250px;
height: 58px;
border: none;
margin-left: 10px;
font-size: 20px;
outline: none;
float: left;
}
.box3_1 {
width: 106px;
height: 60px;
float: left;
background-color: rgb(88, 164, 192);
text-align: center;
line-height: 60px;
color: #fff;
}
.box4 {
width: 100%;
height: 50px;
border-bottom: 1px solid #000;
display: flex;
font-size: 18px;
}
.box4:hover .box4_3{
opacity: 1;
}
.box4_1 {
flex: 2;
height: 50px;
line-height: 50px;
text-align: center;
}
.box4_2 {
flex: 8;
height: 50px;
line-height: 50px;
}
.box4_3 {
flex: 2;
height: 50px;
line-height: 50px;
text-align: center;
opacity: 0;
}
.box4_3:hover{
color: rgb(0, 242, 255);
cursor: pointer;
}
.box5 {
width: 100%;
height: 50px;
display: flex;
font-size: 12px;
}
.box5_1 {
flex: 2;
height: 50px;
line-height: 50px;
text-align: center;
}
.box5_2 {
flex: 8;
height: 50px;
line-height: 50px;
}
.box5_3 {
flex: 2;
height: 50px;
line-height: 50px;
text-align: left;
}
.box5_3:hover{
cursor: pointer;
text-decoration: underline;
}
</style>
</head>
<body style="background-color: rgb(245,245,245);">
<div id="app">
<div class="boss">
<div class="box1">小黑记事本</div>
<div class="box2">
<div class="box3">
<input type="text" placeholder="请输入任务" v-model="obj.rw">
<div @click="tj()" class="box3_1">添加任务</div>
</div>
<div class="box4" v-for="(item,index) of arr">
<div class="box4_1">{{index+1}}.</div>
<div class="box4_2">{{item.rw}}</div>
<div @click="sc(index)" class="box4_3">X</div>
</div>
<div v-show="xs" class="box5">
<div class="box5_1">合计:</div>
<div class="box5_2">{{hjs}}</div>
<div @click="qs()" class="box5_3">清空任务</div>
</div>
</div>
</div>
</div>
</body>
<script src="./vue.js"></script>
<script>
Vue.config.productionTip = false;
var vm = new Vue({
el:"#app",
data(){
return{
arr:[],
arrs:[],
xs:false,
hjs:"",
obj:{
rw:"",
},
}
},
methods:{
tj(){
this.arrs=[];
this.arr.unshift(this.obj)
this.obj={
rw:"",
};
this.hjs=this.arr.length;
if(this.arr.length>0){
this.xs=true
}else if(this.arr.length==0){
this.xs=false
}
},
sc(a){
this.arrs=[];
this.arr.splice(a,1)
this.hjs=this.arr.length;
if(this.arr.length>0){
this.xs=true
}else if(this.arr.length==0){
this.xs=false
}
},
qs(){
this.arr=this.arrs;
if(this.arr.length>0){
this.xs=true
}else if(this.arr.length==0){
this.xs=false
}
}
}
})
</script>
</html>