Vue简易便签实现

news/2024/7/10 2:01:10 标签: html5, vue

Vue简易便签实现

  1. html部分
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>小钱便签</title>
    <!-- 引入自定义样式表 -->
    <link rel="stylesheet" type="text/css" href="index.css"/>
</head>
<body>
	<!-- 主体区域 -->
    <section id="app">
        <!-- 输入框 -->
        <header>
        	<h1 class="title">便签</h1>
        	<input type="text" v-model="inputValue" autofocus="autofocus" 
                   placeholder="请输入事项" autocomplete="off" class="new-todo" 
                   @keyup.enter="add"/>
        </header>
    	<!-- 列表区域 -->
    	<section class="main">
        	<ul class="todo-list">
                <li class="todo" v-for="(item, index) in list">
                	<div class="view">
                        <span class="index">{{ index + 1 }}</span>
                        <label>{{ item }}</label>
                        <button class="destroy" @click="remove(index)">删除</button>
                    </div>
                </li>
            </ul>
        </section>
    	<!-- 统计和清空 -->
        <footer class="footer">
            <span class="todo-count" v-if="list.length != 0">{{ list.length }}<strong></strong>@nbsp;items left</span>
            <button @click="clear" v-show="list.length != 0">Clear</button>
        </footer>
    </section>
    <!-- 底部 -->
    <footer class="info">
        <p>
            <a href="https://www.baidu.com/"><img src="https://www.baidu.com/img/flexible/logo/pc/result.png"/></a>
        </p>
    </footer>    
    <!-- 开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
    	var app = new Vue({
            el: '#app',
            data: {
                list: ["糖醋里脊", "红烧狮子头", "蒸鸡蛋"],
                // 初始化输入值为空
                inputValue: ""
            },
            methods: {
                add: function() {
                    this.list.push(this.inputValue);
                },
                remove: function(index) {
                    this.list.splice(index, 1);
                },
                clear: function() {
                    this.list = []
                }
            }
        })
    </script>
</body>    
</html>
  1. css样式表
* {
    padding: 0;
    margin: 0;
}

#app {
    width: 300px;
    /* 盒子居中对齐 */
    margin: 5px auto;
    box-shadow: 0px 3px 10x 2px rgba(0, 0, 0, 0.1);
}

.title {
    font: normal 200 34px '微软雅黑';
    color: rgb(219, 82, 82);
    text-align: center;
    padding-top: 100px;
    padding-bottom: 10px;
}

.new-todo {
    width: 100%;
    height: 40px;
    padding-left: 10px;
    color: rgb(88, 88, 88);
    box-sizing: border-box;
    border: 1px solid rgb(236, 236, 236);
}

.new-todo:focus {
    outline: none;
}

.footer {
    position: relative;
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    border: 1px solid rgb(236, 236, 236);
    background-color: white;
}

.footer span {
    font-size: 12px;
    color: rgb(131, 131, 131);
    float: left;
    line-height: 40px;
}

.todo-count {
    margin-left: 10px;
}

.clear-button {
    margin-left: 170px;
}

.todo {
    list-style: none;
    font-size: 14px;
    font-family: '微软雅黑';
    color: rgb(88, 88, 88);
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    line-height: 40px;
    border: 1px solid rgb(236, 236, 236);
    background-color: white;
}

.view {
    position: relative;
    margin-left: 10px;
}

.view label {
    width: 200px;
    height: 40px;
    position: absolute;
    /* 超出的文本隐藏 */
    overflow: hidden;
    /* 溢出用省略号表示 */
    text-overflow: ellipsis;
    /* 溢出不换行 */
    white-space: nowrap;
}

.destroy {
    position: absolute;
    right: 10px;
    top: 9px;
    font-size: 12px;
    font-family: '微软雅黑';
    outline: none;
    border: 1px solid rgb(236, 236, 236);
    color: rgb(255, 111, 111);
    display: none;
}

.view:hover .destroy {
    display: block;
}

.footer button {
    position: absolute;
    right: 10px;
    top: 9px;
    font-size: 12px;
    font-family: '微软雅黑';
    outline: none;
    border: 0px;
    color: rgb(131, 131, 131);
}

.info {
    margin: 5px auto;
    width: 300px;
}

.info a {
    padding-left: 50px;
}

在这里插入图片描述


http://www.niftyadmin.cn/n/230679.html

相关文章

带你走进Flutter 3.7

期待已久的新教程上线啦&#xff01;解锁Flutter开发新姿势&#xff0c;一网打尽Flutter最新与最热技术&#xff0c;点我Get!!! 新年伊始&#xff0c;由 Flutter 3.7 正式版来「打头阵」&#xff01;我们与整个 Flutter 社区们继续在 Flutter 3.7 中优化了框架&#xff0c;包括…

Linux eval将一个字符串作为命令执行

eval用来在执行命令时作二次解析&#xff1a;主要是每次执行一个shell命令它会先检察一次&#xff0c;看到有$标志就会把值替换一次&#xff0c;然后再执行一遍。eval不会唤起起另一个shell来执行&#xff0c;而是在本身这个shell内多解析一次&#xff0c;所以替换的结果可以保…

Netty的SO_LINGER不要随便用

SO_LINGER SO_LINGER是一个Socket选项&#xff0c;它决定一个Socket关闭时的行为&#xff0c;因此配在server端配置的时候使用childOption配置&#xff0c;该选项针对每个连接配置生效&#xff0c;而不是全局性的配置。 该配置主要在阻塞IO的关闭场景下用的更多&#xff0c;当…

MAC-安装Java环境、JDK配置、IDEA插件推荐

背景&#xff1a;发现经常换电脑装环境等比较麻烦&#xff0c;主要还是想记录一下&#xff0c;不要每次安装都到处翻。。 1、下载并安装JDK 到官网下载所需的JDK&#xff1a;https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html 这儿下…

Python 智能项目:6~10

原文&#xff1a;Intelligent Projects Using Python 协议&#xff1a;CC BY-NC-SA 4.0 译者&#xff1a;飞龙 本文来自【ApacheCN 深度学习 译文集】&#xff0c;采用译后编辑&#xff08;MTPE&#xff09;流程来尽可能提升效率。 不要担心自己的形象&#xff0c;只关心如何实…

Baumer工业相机堡盟工业相机如何通过BGAPISDK设置显示彩色相机和黑白相机的图像(C++)

Baumer工业相机堡盟工业相机如何通过BGAPISDK设置显示彩色相机和黑白相机的图像&#xff08;C&#xff09;Baumer工业相机Baumer工业相机的彩色和黑白成像的技术背景Baumer工业相机通过BGAPI SDK在回调函数里显示图像彩色工业相机在BufferEvent显示图像黑白工业相机在BufferEve…

如何使用Thymeleaf给web项目中的网页渲染显示动态数据?

编译软件&#xff1a;IntelliJ IDEA 2019.2.4 x64 操作系统&#xff1a;win10 x64 位 家庭版 服务器软件&#xff1a;apache-tomcat-8.5.27 目录一. 什么是Thymeleaf&#xff1f;二. MVC2.1 为什么需要MVC&#xff1f;2.2 MVC是什么&#xff1f;2.3 MVC和三层架构之间的关系及工…

虚拟化技术:实现资源高效利用和灵活管理的利器

虚拟化技术是一种通过软件或硬件手段&#xff0c;将物理资源抽象化&#xff0c;从而创建虚拟资源的技术。这种技术可以应用于计算、存储、网络等领域&#xff0c;通过将物理资源划分为多个虚拟资源&#xff0c;使得多个应用程序或用户可以共享同一组物理资源&#xff0c;从而提…