本文实例为大家分享了Vue实现简易记事本的具体代码,供大家参考,具体内容如下 预览图: 功能如下: (1)输入任务并按下回车键,可将任务添加至任务列表(不可输入重复任务) (2)
本文实例为大家分享了Vue实现简易记事本的具体代码,供大家参考,具体内容如下
预览图:
功能如下:
(1)输入任务并按下回车键,可将任务添加至任务列表(不可输入重复任务)
(2)点击删除,可删除对应任务
(3)点击清空,所有任务都会被删除
(4)左下角同步显示任务总数
完整代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta Http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>记事本</title>
<style>
* {
margin: 0;
padding: 0;
}
#todoapp {
width: 600px;
background-color: rgba(19, 161, 114, 0.63);
font-family: sans-serif;
}
.header>h1 {
padding: 20px 0;
text-align: center;
font-size: 40px;
color: whitesmoke;
}
.newTask {
display: block;
width: 500px;
height: 50px;
line-height: 50px;
padding-left: 10px;
margin: 0 auto;
font-size: 20px;
outline: none;
border: none;
}
.todolist li {
height: 30px;
line-height: 30px;
padding-left: 15px;
margin: 10px 0;
font-size: 25px;
color: white;
}
.todolist .item {
margin-left: 15px;
}
.destroy,
.clear {
width: 50px;
height: 30px;
float: right;
color: white;
background-color: transparent;
border: none;
font-size: 20px;
}
.footer {
width: 600px;
height: 30px;
padding: 10px 0;
vertical-align: middle;
}
.footer p {
display: inline-block;
padding-left: 15px;
color: white;
font-size: 20px;
}
</style>
</head>
<body>
<section id="todoapp">
<header class="header">
<h1>记事本</h1>
<input type="text" v-model="newItem" class="newTask" placeholder="请输入任务" @keyup.enter="add">
</header>
<section>
<ul class="todolist">
<li v-for="(item, index) in list">
<div>
<span>{{ index + 1 }}</span>
<label class="item">{{ item }}</label>
<button class="destroy" @click="del(index)">删除</button>
</div>
</li>
</ul>
</section>
<footer class="footer">
<p class="count">
items: {{ list.length }}
</p>
<button class="clear" @click="clear" v-show="list.length != 0">清空</button>
</footer>
</section>
<script src="https://cdn.bootCSS.com/vue/2.4.2/vue.min.js"></script>
<script>
const app = new Vue({
el: "#todoapp",
data: {
list: [],
newItem: ""
},
methods: {
add() {
if (this.newItem == "") {
return;
}
else {
if (!this.list.includes(this.newItem)) {
this.list.push(this.newItem);
this.newItem = "";
}
else {
alert("请勿添加重复事件!");
this.newItem = "";
}
}
},
del(index) {
this.list.splice(index, 1);
},
clear() {
this.list = [];
}
}
})
</script>
</body>
</html>
--结束END--
本文标题: Vue实现简易记事本
本文链接: https://www.lsjlt.com/news/145563.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模 安全指南 Osprey 游戏分析 游戏调试 游戏图形 游戏物理 开源库
0