自学前端第二天——实现计划表单

代码项目来源:

VUE小案例 - 记事本 - 掘金

效果:

本人学习过程中修改过的最终代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- S 主体 -->
    <section id="note" class="mainZone">
        <!-- S 头部 -->
        <header class="headZone">
            <div>邵奎令记事</div>
            <input class="textInput" type="text" placeholder="别偷懒,请输入任务吧" v-model="message" @keyup.enter="addList">
            <button @click="clearTextBox" class="clearButton">清空</button>
        </header>
        <!-- E 头部 -->
        <!-- S 列表区域 -->
        <section class="listZone">
            <div class="tips" v-show="listMsg.length===0">还没有任务请添加一个吧</div>
            <div v-for="(item,index) in listMsg" @dblclick="delectMsg(index)" @click="finishMsg(index)"
                :class="item.class" v-show="listMsg.length>0">{{index + 1}} . {{item.text}}</div>
        </section>
        <!-- E 列表区域 -->
        <!-- S 底部功能按键 -->
        <footer class="bottleZone">
            <span class="countzone" v-text="count+' items left'"></span>
            <span class="clearbtn" @click="clearMsg">CLEAR</span>
        </footer>
        <!-- E 底部功能按键 -->
    </section>
    <!-- E 主体 -->





    <!-- VUE2开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let app = new Vue({
            el: '#note',
            data: {
                message: "",
                listMsg: [],
                count: 0
            },
            methods: {
                addList() {
                    if (this.message !== "") {
                        this.listMsg.push({ text: this.message, class: 'todo' });
                        this.count += 1
                        this.message = "";
                    }
                },
                delectMsg(index) {
                    this.listMsg.splice(index, 1);
                    this.count -= 1
                },
                finishMsg(index) {
                    this.listMsg[index].class = 'todo finish'
                },
                clearMsg() {
                    this.listMsg = [];
                    this.count = 0
                },
                clearTextBox() {
                    this.message = ""; // 清空文本框
                }
            }
        })
    </script>




    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul li {
            list-style: none;
        }

        .clearButton {
            position: absolute;
            right: 15px;
            /* 调整按钮与输入框的距离 */
            top: 25%;
            /* 居中垂直对齐 */
            transform: translateY(-50%);
            background-color: #f44336;
            /* 红色背景 */
            color: white;
            /* 白色文字 */
            border: none;
            /* 没有边框 */
            padding: 10px 20px;
            /* 添加一些内边距 */
            text-align: center;
            /* 文字居中 */
            text-decoration: none;
            /* 没有下划线 */
            display: inline-block;
            /* 行内块元素 */
            font-size: 16px;
            /* 字体大小 */
            border-radius: 5px;
            /* 圆角边框 */
            cursor: pointer;
            /* 鼠标指针样式为手型 */
        }

        .clearButton:hover {
            background-color: #d32f2f;
            /* 鼠标悬停时的背景颜色 */
        }


        .mainZone {
            position: relative;
            width: 580px;
            min-height: 500px;
            margin: 10px auto;
            text-align: center;
            background-color: rgb(189, 221, 176);
            box-shadow: 0 1px 1px rgba(26, 56, 41, 0.2), 0 8px 0 -3px #698870, 0 9px 1px -3px rgb(0 0 0 / 20%), 0 16px 0 -6px #4e6653, 0 17px 2px -6px rgb(0 0 0 / 20%);
        }

        .headZone {
            height: 180px;
            line-height: 80px;
            font-size: 30px;
            font-weight: 400;
            font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', '楷体';
            color: rgb(94, 49, 17);
            text-shadow: 1px 1px 3px rgb(122, 83, 83)
        }

        .textInput {
            padding-right: 1px; /* 留出按钮的空间 */
            width: 400px;
            height: 50px;
            text-indent: 20px;
            font-size: 18px;
            border: none;
            outline: none;
            border-radius: 10px;
            color: rgb(99, 30, 30);
            background-color: rgba(188, 201, 144, 0.6);
        }

        .listZone {
            padding-bottom: 50px;
        }

        .listZone .tips {
            line-height: 200px;
            font-size: 20px;
            text-indent: 10px;
            color: rgb(116, 64, 64, .5);
        }

        .listZone .todo {
            width: 500px;
            height: 40px;
            margin: 5px auto;
            line-height: 40px;
            font-size: 20px;
            text-align: left;
            text-indent: 10px;
            font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', '楷体';
            color: rgb(116, 64, 64);
            cursor: pointer;
            background-color: rgba(188, 201, 144, 0.6);
            border-radius: 10px;
            box-shadow: inset 1px 1px 5px rgba(129, 138, 99, 0.6);
        }

        .listZone .finish {
            text-decoration: line-through;
            background-color: rgba(121, 129, 95, 0.8);
            box-shadow: inset 2px 2px 1px rgb(122, 99, 99);
        }

        .bottleZone {
            position: absolute;
            bottom: 0;
            right: 20px;
            /* width: 100%; */
            height: 50px;
            line-height: 50px;
        }

        .clearbtn {
            color: rgba(179, 120, 120, 0.6);
            font-weight: 400;
            cursor: pointer;
        }

        .countzone {
            margin-right: 400px;
            color: rgba(179, 120, 120, 0.6);
            font-weight: 400;
            cursor: pointer;
        }
    </style>

</body>

</html>

问题:

1、<section id="note" class="mainZone">

2、与section用法类同的还有哪些属性

3、 <input class="textInput" type="text" placeholder="别偷懒,请输入任务吧" v-model="message" @keyup.enter="addList">

4、<input>标签中的属性有哪些

5、

6、

<section class="listZone">

<div class="tips" v-show="listMsg.length===0">还没有任务请添加一个吧</div>

<div v-for="(item,index) in listMsg" @dblclick="delectMsg(index)" @click="finishMsg(index)"

:class="item.class" v-show="listMsg.length>0">{{index + 1}} . {{item.text}}</div>

</section>这代码啥意思

7、:class="item.class" 这里不太懂,根据那个样式绑定的,item代表的又是啥

8、{{}}

9、

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
好的,今天我们来学习Python中的字典(Dictionary)。 字典是一种无序的、可变的数据类型,它以键值对(key-value)的形式存储数据,其中键(key)必须是唯一的,而值(value)可以是任意数据类型。字典用花括号{}表示,每个键值对之间用逗号隔开。 下面是一个简单的字典示例: ``` my_dict = {'name': '张三', 'age': 18, 'gender': '男'} ``` 这个字典中,'name'、'age'、'gender'就是键,而'张三'、18、'男'就是相应的值。 可以使用`dict()`函数来创建一个字典,也可以使用`{}`来创建一个空字典。 接下来,我们来看一些常用的字典操作。 1. 访问字典元素 可以通过键来访问字典中的元素,例如: ``` print(my_dict['name']) # 输出:张三 ``` 如果键不存在,则会抛出KeyError异常。 2. 修改字典元素 可以通过键来修改字典中的元素,例如: ``` my_dict['age'] = 20 print(my_dict) # 输出:{'name': '张三', 'age': 20, 'gender': '男'} ``` 3. 添加字典元素 可以通过键来添加字典中的元素,例如: ``` my_dict['address'] = '北京市' print(my_dict) # 输出:{'name': '张三', 'age': 20, 'gender': '男', 'address': '北京市'} ``` 4. 删除字典元素 可以通过键来删除字典中的元素,例如: ``` del my_dict['gender'] print(my_dict) # 输出:{'name': '张三', 'age': 20, 'address': '北京市'} ``` 5. 字典长度 可以使用`len()`函数来获取字典的长度,例如: ``` print(len(my_dict)) # 输出:3 ``` 6. 字典遍历 可以使用`items()`方法来遍历字典中的每一个键值对,例如: ``` for key, value in my_dict.items(): print(key, value) ``` 输出: ``` name 张三 age 20 address 北京市 ``` 通过上述操作,我们可以初步了解字典的基本用法。在实际应用中,字典是非常重要的数据类型,它可以用来存储和处理各种复杂的数据结构。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵桑..

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值