任务列表vue

这是一个使用Vue.js框架编写的TodoList应用程序,包含HTML结构、CSS样式和JavaScript逻辑。用户可以查看任务列表,标记任务为已完成,添加新任务,以及编辑现有任务。应用实时更新任务状态,并显示未完成任务的数量。
摘要由CSDN通过智能技术生成

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="css/bootstrap.css">

    <title>TodoList</title>

    <style>

        .container{

            width: 500px;

            margin: 0 auto;

        }

        .a{

            color: aqua;

            text-decoration: none;

        }

        li{

            list-style-type: none;

            font-size: 20px;

            margin-top: 10px;

        }

        .sp{

            color: #ccc;

            text-decoration: line-through;

        }

    </style>

</head>

<body>

    <div id="app" class="container">

        <h1>任务列表</h1>

        <h3>任务总数还有{{list.length}};还有:{{ excess() }} 未完成; [<span class="a" @click="success()">完成</span>]

        <ul style="margin-top: 30px;">

            <li  v-for="(item,index) in list">

                <input type="checkbox" v-model="item.bol">&nbsp;&nbsp;

                <span v-show="!item.edit" @click="input(index)" v-bind:class="{'sp' : item.bol}" @click>{{item.des}}</span>

                <input type="text" v-model="item.des" v-show="item.edit" value="item.des" @blur="bluei(index)">

            </li>

        </ul>

        <input type="text" name="" v-model="msg" id="">

        <button @click="add()">添加</button>

    </div>

</body>

<script src="https://cdn.jsdelivr.net/npm/vue"></script>

<script>

    let app={

        data(){

            return{

                msg:"",

                list :[

                    {

                        des: "编写java代码",

                        bol: false,

                        edit: false

                    },

                    {

                        des: "UI设计",

                        bol: false,

                        edit: false

                    },

                    {

                        des: "编写页面代码",

                        bol: false,

                        edit: false

                    },

                    {

                        des: "编写js代码",

                        bol: false,

                        edit: false

                    }

                ]

            }

        },

        methods:{

            excess(){

                let num=0;

                for (let index = 0; index < this.list.length; index++) {

                   if(!(this.list[index].bol)){

                        num++;

                   }

                }

                return num;

            },

            input(index){

                this.list[index].edit=true;

            },

            success(){

                let arr=[];

                for(let i=0;i<this.list.length;i++){

                    if(!this.list[i].bol){

                        arr.push(this.list[i])

                    }

                }

                this.list=arr;

            },

           

            bluei(index){

                this.list[index].edit=false;

            },

            add(){

                let item={

                    des: this.msg,

                    bol: false,

                    edit: false

                }

                this.list.push(item);

            }

        }

    }

    Vue.createApp(app).mount("#app");

</script>

</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值