VUE简易计划清单

目录

效果预览图

完整代码


效果预览图

完整代码

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #app{
            width: 600px;
            height: 800px;
            background: #ccc;
            margin: 50px auto;
            padding: 20px;
        }
        #app>input{
            width: 450px;
            height: 50px;
            border: none;
            margin: 30px;
        }
        #app>button{
            width: 80px;
            height: 50px;
            border: none;
            background: #9ddeec;
        }
        h3{
            margin-left: 30px;
        }
        ul{
            list-style-type: none;
            height: 300px;
            overflow: auto;
            margin-top: 10px;
        }
        .t{
            width: 530px;
            margin: 0 auto;
            height: 40px;
            margin-top: 10px;
            background: #fff;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: space-around;
            position: relative;
        }
        li{
            position: relative;
        }
        span{
            display: inline-block;
            width: 250px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #app>ul>li>button{
            height: 30px;
            width: 60px;
            border: none;
            cursor: pointer;
        }
        var{
            font-size: 12px;
            color: #ccc;
        }
        #app .ck{
            width: 530px;
            height: 100px;
            margin: 0 auto;
            display: none;
            background: #fff;
            z-index: 100;
            position: relative;
            overflow: auto;
            
        }
        .kk{
             white-space: wrap;
        }
        .ck button{
            width: 30px;
            height: 30px;
            border: none;
            position: absolute;
            right: 3px;
            bottom: 3px;
            cursor: pointer;
        }
        li .m{
            border: none;
            background: #8cbde5;
            width: 60px;
            height: 30px;
            border-radius: 5px;
            color: #fff;
        }
        .hc{
           position: absolute;
           width: 100%;
           height: 100%;
           background: rgba(0,0,0,0.3);
           border-radius: 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <input type="text" v-model="val">
        <button @click="add">添加</button>
        <h3>待完成事项</h3>
        <ul>
            <li v-for="(item,index) in arr">
                <div class="t">
                     <input type="checkbox" v-model="item.bol" @change="xz(index)">
                 <span>{{arr[index].name}}</span> 
                 <var>{{arr[index].time}}</var>
                <button class="m" @click="sc(index)">删除</button>
                <button class="m" @click="ck(index)">查看详情</button> 
                </div>
                  <div :style="{display:n == index ?'block':'none'}" class="ck">
                    <p class="kk">{{arr[index].name}}</p> 
                    <button @click="sq">收起</button>
                  </div>
            </li>
           
            
        </ul>
        <h3>已完成事项</h3>
        <ul>
            <li v-for="(item,index) in arr2">
                <div class="t">
                     <input type="checkbox" v-model="item.bol" @change="xz(index)">
                 <span>{{arr2[index].name}}</span> 
                 <var>{{arr2[index].time}}</var>
                 <div class="hc" @click="bb"></div>
            </li>
        </ul>
    </div>
</body>
</html>
<script type="module">
 import {createApp} from './js/vue.esm-browser.js'
 createApp({
    data() {
        return {
            arr:[
                {name:'早上:早起背面试题',time:'2023/11/22 18:36:00',bol:false},
                {name:'上午:学习',time:'2023/11/22 18:06:00',bol:false},
                {name:'中午:午休',time:'2023/11/22 17:35:00',bol:false},
                {name:'晚上:复习',time:'2023/11/22 14:36:00',bol:false},
            ],
            arr2:[],
            val:'',
            n:-1,
            num:0,
            fl:1,
          }
    },
    methods: {
        sc(index){
           
            let userResponse = window.confirm("确定要删除该计划吗?");
            if (userResponse) {
                this.arr.splice(index,1)
            } else {
              
            }
        },
        xz(index){
            let userResponse = window.confirm("确定已经完成了该计划吗");
            if (userResponse) {
            this.arr2.push(this.arr[index])
            this.arr.splice(index,1)
            console.log(this.arr2);
            } else {
              this.arr[index].bol = false
            }
        },
        add(){
           let nn = new Date().toLocaleString()
            console.log(this.val);
            if (this.val!='') {
                 let obj={
                name:this.val,
                time:nn
            }
            this.arr.unshift(obj)
            this.val=''
            }else if (this.val=='') {
                alert('内容不能为空')
            }
        },
        ck(index){
           this.n = index;
        },
        sq(){
            this.n = -1
        },
        bb(){
            alert('已经确定完成的计划不能查看点击!')
        }
    },

 }).mount('#app')    
</script>
相关推荐
腻害兔1 小时前
【若依项目-产品经理视角】深度拆解 RuoYi-Vue-Pro 商城模块:从商品管理到交易引擎,50 张表撑起一整套电商系统
java·大数据·vue.js·产品经理·ai编程
sugar__salt8 小时前
Vue3 表单双向绑定与响应式核心 API 技术详解
前端·javascript·vue.js
郝亚军8 小时前
使用Vue 3和Nginx打包和部署Vue.js项目的一般步骤
前端·vue.js·nginx
阿懂在掘金10 小时前
企业级命令式弹窗方案:三行代码适配已有 Dialog
前端·vue.js·前端框架
YWL11 小时前
OpenLayers + Vue 2 使用指南(01)
前端·javascript·vue.js
达子66611 小时前
第8章_HarmonyOs开发图解 剪贴板
vue.js
森林的尽头是阳光13 小时前
tree回显问题
javascript·vue.js·elementui
qetfw14 小时前
MWU:Vue 3 + FastAPI 的 MaaFramework 跨平台 WebUI 源码
前端·vue.js·python·fastapi·开源项目·效率工具
mfxcyh14 小时前
Vue3+Ant Design Vue 实现手动异步文件上传(含大小校验、弹窗上传)
前端·javascript·vue.js
meilindehuzi_a14 小时前
Vue3进阶基础:指令修饰符、v-model表单绑定、动态样式、计算属性与侦听器实战
前端·javascript·vue.js