HTML相关

<!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>

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值