使用Vue框架如何制作具有简单功能的记事本
Admin 2022-07-08 群英技术资讯 1103 次浏览
今天这篇我们来学习和了解“使用Vue框架如何制作具有简单功能的记事本”,下文的讲解详细,步骤过程清晰,对大家进一步学习和理解“使用Vue框架如何制作具有简单功能的记事本”有一定的帮助。有这方面学习需要的朋友就继续往下看吧!本文实例为大家分享了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="./vue.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>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了js删除对象中的某一个字段的方法实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
本文主要是给大家简单介绍了Array的相关基础知识,到这里也算是能对Array有更全面的理解了,希望大家能够喜欢,后续我们将继续介绍关于array的内容。
对象有两种属性,普通的数据属性和访问器属性。访问器属性本质上是用于获取和设置值的函数(可以拦截、过滤、处理等操作要设置或获取的属性),但从外部代码来看就像传统属性一样。
实现点击跳转页面的方法:1、给按钮元素绑定click点击事件,指定事件处理函数;2、在事件处理函数中利用“window.location.href”属性实现页面跳转,语法为“window.location.href="指定页面路径";”。
想要制作一个轮播图我们要先弄清楚他的原理,如何能让图片自右向左滑动?轮播图是网页开发中经常见到的效果,购物网站,视频网站,社区论坛等等网站都会应用到,那么轮播图是如何制作的呢?首先,我们需要搞懂轮播图的实现原理,下面是让图片自右向左滑动的原理以及代码实现,感兴趣的朋友继续往下看吧。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008