Vue待办事项的实现

这篇文章介绍了如何使用Vue.js构建一个具有拖拽功能的待办事项列表,包括添加、编辑、删除和状态切换,展示了前端开发中组件化和交互设计的应用。
摘要由CSDN通过智能技术生成

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <style>
            * {
                padding: 0;
                margin: 0;
            }

            ul,
            ol {
                list-style: none;
            }

            a {
                text-decoration: none;
            }

            body {
                background-color: darkgray;
            }

            header {
                width: 100%;
                min-width: 1434px;
                height: 50px;
                background-color: rgba(47, 47, 47, 0.98);
            }

            header section {
                width: 600px;
                height: 50px;
                margin: 0px auto;
            }

            header section label {
                width: 100px;
                color: rgb(221, 221, 221);
                line-height: 50px;
                font-size: 24px;
                float: left;
            }

            header section input {
                width: 360px;
                height: 24px;
                margin-top: 12px;
                float: right;
                padding-left: 20px;
                padding-top: 1px;
                padding-right: 2px;
                padding-bottom: 1px;
                border-radius: 5px 5px 5px 5px;
                border: none;
                outline: none;
            }

            section h2 {
                width: 600px;
                height: 32px;
                margin: 0px auto;
                margin-top: 20px;
                margin-bottom: 20px;
            }

            section span {
                float: right;
                background-color: rgb(230, 230, 250);
                width: 9px;
                height: 20px;
                padding-left: 5px;
                padding-right: 5px;
                border-radius: 50px;
                font-size: 14px;
                line-height: 20px;
            }

            section {
                width: 600px;
                margin: 0px auto;
            }

            footer {
                width: 600px;
                margin: 0px auto;
                text-align: center;
                color: rgb(102, 102, 102);
                font-size: 14px;
            }

            footer a {

                color: rgb(153, 153, 153);
            }
            ol li{
                width: 600px;
                height: 32px;
                position: relative;
                margin-bottom: 10px;
            }
            ol li input{
                width: 22px;
                height: 22px;
                margin-top: 2px;
                top: 2px;
                left: 10px;
                margin-left: 4px;
                position: absolute;
            }
            ol li p{
                width: 506px;
                height: 32px;
                float: left;
                padding-left: 45px;
                padding-right: 45px;
                background-color: rgb(255, 255, 255);
                border-left: 5px solid rgb(98, 154, 156);
                line-height: 32px;
            }
            ol li a{
                width: 14px;
                height: 12px;
                right: 5px;
                top: 5px;
                position: absolute;
                border: 6px solid rgb(255, 255, 255);
                background-color: rgb(204, 204, 204);
                margin-left: 2px;
                font-size: 14px;
                padding-left: 6px;
                border-radius: 14px 14px 14px 14px;
                color: rgb(255, 255, 255);
            }
            ul li{
                width: 600px;
                height: 32px;
                position: relative;
                margin-bottom: 10px;
            }
            ul li input{
                width: 22px;
                height: 22px;
                margin-top: 2px;
                top: 2px;
                left: 10px;
                margin-left: 4px;
                position: absolute;
            }
            ul li p{
                width: 506px;
                height: 32px;
                float: left;
                padding-left: 45px;
                padding-right: 45px;
                background-color: rgb(255, 255, 255);
                border-left: 5px solid rgb(98, 154, 156);
                line-height: 32px;
            }
            ul li a{
                width: 14px;
                height: 12px;
                right: 5px;
                top: 5px;
                position: absolute;
                border: 6px solid rgb(255, 255, 255);
                background-color: rgb(204, 204, 204);
                margin-left: 2px;
                font-size: 14px;
                padding-left: 6px;
                border-radius: 14px 14px 14px 14px;
                color: rgb(255, 255, 255);
            }
        </style>

        <div id="app">
            <header>
                <section>
                    <form action="javascript:postaction()" id="form">
                        <label for="title">ToDoList</label>
                        <input type="text" id="title" name="title" placeholder="添加ToDo" required="required"
                            autocomplete="off" v-model="message" @keydown="down($event)">

                    </form>
                </section>
            </header>
            <section>
                <!--          οnclick="save()" -->
                <h2>正在进行 <span id="todocount">{{arr.length}}
                </span></h2>
                <ol id="todolist" class="demo-box">
                    <li draggable="true"><input type="checkbox" @change="update(index)" v-for="(item,index) in arr" :key="item">
                        <p id="p-0" οnclick="edit(0)">{{item}}</p><a href="javascript:remove(0)" @click="removed(index)">-</a>
                    </li>
                </ol>
                <h2>已经完成 <span id="donecount">{{Arrays.length}}</span></h2>
                <ul id="donelist" >
                    <li draggable="true"><input type="checkbox" @change="date(index)"  v-for="(item,index) in Arrays" :key="item" checked >
                        <p id="p-0" οnclick="edit(0)">{{item}}</p><a href="javascript:remove(0)" @click="remove(index)">-</a>
                    </li>
                </ul>
            </section>
            <footer>
                Copyright © 2024 todolist.cn <a href="javascript:clear();" @click="clear()">clear</a>
            </footer>
        </div>
        <script src='lib/vue.global.js'></script>
        <script>
            const {
                createApp
            } = Vue

            const app = createApp({
                data() {
                    return {
                        message: '',
                        arr: [],
                        Arrays:[]
                    }
                },
                methods: {
                    down(e) {
                        if (e.keyCode === 13&&this.message.trim()!='') {
                            this.arr.push(this.message)
                            this.message=' '
                        }
                    },
                    update(i){
                            this.Arrays.push(this.arr[i])
                        this.arr=this.arr.filter((item,index)=>{
                            return i!=index
                        })
                    
                    },
                    date(i){
                        this.arr.push(this.Arrays[i])
                        this.Arrays=this.Arrays.filter((item,index)=>{
                                return i!=index
                            })
                    
                        
                    },
                    remove(i){
                        this.Arrays=this.Arrays.filter((item,index)=>{
                                return i!=index
                            })
                    },
                    removed(i){
                        this.arr=this.arr.filter((item,index)=>{
                                return i!=index
                            })
                    },
                    clear(){
                        this.Arrays=[]
                        this.arr=[]
                    }
                }
            })
            app.mount('#app')
        </script>
    </body>
</html>

  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vue-demo 青否云 vue demo 官网 http://cloud.qingful.com 演示 https://qingful.github.io/jquery-demo/index.html 账号:13253522080 密码:mmmmmm 使用 登录青否云 创建应用 数据设置。 创建数据表。 创建数据表user,引擎和校对默认即可。点击显示结构,添加字段phone,类型选择bigint,长度值为11,其余默认。添加字段password,类型选择text,其余默认。 创建数据表todos,引擎和校对默认即可。点击显示结构,添加字段content,类型选择text,其余默认。添加字段user_id,类型选择int,其余默认。添加字段status,类型选择int,其余默认。 权限设置。 创建密钥,名称Authorization,密钥随便设置。 创建分组,分别创建public和home分组。 组权限,创建home的组权限,并选择Authorization秘钥。 表权限。 创建todos表权限,选择home分组,选择todos数据表,权限勾选查询、新增、更新、删除,密钥选择为空。 创建user表权限,选择public分组,选择user数据表,权限勾选查询、新增,密钥选择为Authorization。 字段。 点击创建字段,选择public分组,user数据表,password字段,值为空,类型选择md5,传值选择是,请求链接选择为空。 点击创建字段,选择home分组,todos数据表,user_id字段,值为Authorization.id。类型为空,传值选择否,请求链接选择为空。 配置下./src/config/config.js中的appid,appkey 运行npm run dev 青否云 一站式后端云服务解决方案。为H5,小程序,APP等应用,提供高效,简单,安全的后端云服务支持。 高效 开发效率 无需开发数据库增删改查,登录授权验证,短信验证码等基础功能。 人员成本 无需运维人员,后端仅需要设计数据库,关联,授权等功能的人员。 运维时间 无需搭建服务器,也无需运维,运维自动化时间节省100%。 简单 sdk集成 sdk一键集成,极速部署,辅助开发文档,开发范例等快速的上手开发。 api接口 api接口采用restful设计方案,拥有结构清晰、符合标准、易于理解、扩展方便等特性。 cdn加速 cdn加速内置,融合主流CDN,加速传输,助力内容极速抵达用户。 安全 jwt授权 JSON Web Token(JWT)是JSON风格轻量级的授权和身份认证规范,可实现无状态、分布式的Web应用授权。使用JWT在用户和服务器之间传递安全可靠的信息。 https传输 https传输是服务器以密文的方式将对称密钥发给客户端(用公钥进行非对称加解密(TLS握手阶段)对称密钥建立受保护区),非对称加密可以很好的管理对称密钥,保证每次数据加密的对称密钥都是不相同的,通过这个对称密钥来进行后续通信的数据加解密。 sla标准 sla可靠性不低于 99.95%,即每月服务故障时长不超过21.6分钟。并且具备完善的故障监控、自动告警、快速定位、快速恢复等一系列故障应急响应机制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值