Vue便签的简单实现
作者:快乐江小鱼 时间:2024-05-02 17:03:31
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" rel="external nofollow" />
</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/" rel="external nofollow" ><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>
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;
}
来源:https://blog.csdn.net/dolly_baby/article/details/130190051
标签:Vue,便签
0
投稿
猜你喜欢
详解python使用pip安装第三方库(工具包)速度慢、超时、失败的解决方案
2023-11-24 18:03:27
PHP实现将MySQL重复ID二维数组重组为三维数组的方法
2023-11-18 03:28:57
python 中的 asyncio 异步协程
2022-09-15 12:30:53
Python的GUI编程之Pack、Place、Grid的区别说明
2022-10-19 05:53:57
在Dreamweaver MX中应用“占位图形”
2009-07-10 13:16:00
python使用正则表达式匹配字符串开头并打印示例
2021-07-02 00:52:13
javascript中判断一个值是否在数组中并没有直接使用
2024-05-13 10:38:28
golang bufio包中Write方法的深入讲解
2024-05-08 10:45:31
Python paramiko模块的使用示例
2021-05-12 20:30:00
sql通过日期判断年龄函数的示例代码
2024-01-13 21:01:02
sql server几种Join的区别测试方法
2024-01-13 14:54:18
快速了解Python相对导入
2023-07-29 18:35:30
Python实现AI自动抠图实例解析
2021-12-25 11:04:22
Python+seaborn实现联合分布图的绘制
2022-06-14 01:23:53
浅谈Python3实现两个矩形的交并比(IoU)
2021-09-06 19:31:56
webpack多入口文件页面打包配置详解
2024-05-25 15:18:07
python抓取网站的图片并下载到本地的方法
2022-05-19 23:45:08
xorm根据数据库生成go model文件的操作
2024-01-16 00:29:22
用Python的urllib库提交WEB表单
2023-06-11 00:14:52
SQL Server 定时访问url激活数据同步示例
2024-01-24 11:22:50