使用Vue框架如何制作具有简单功能的记事本
Admin 2022-07-08 群英技术资讯 805 次浏览
今天这篇我们来学习和了解“使用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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
目录proxyTable配置和部署服务器1.在config中的index2.在调取接口的方法中proxyTable代理参数含义proxyTable配置和部署服务器在本地创建node.js服务器,前端访问本地接口需要设置跨域1.在config中的index找到proxyTable,完成以下设置proxyTable: {‘
ES5和ES6中的apply异同在哪?在ES6中,新增了一个全局、内建、不可构造的Reflect对象,而且还提供了其下一系列可被拦截的操作方法。而其中的一个方法就是Reflect.apply(),我们知道ES5中也有apply,那么Reflect.apply()和ES5的Function.prototype.apply()有哪些区别和相同的地方呢?
小程序书架功能的实现代码是什么?本文实例为大家分享了微信小程序实现书架功能的具体代码,供大家参考,具体内容如下
jquery怎么修改data-optionsHtml5 data-* 属性定义和用法:data-* 属性用于存储页面或应用程序的私有自定义数据。data-* 属性赋予我们在所有 HTML 元素上嵌入自定义 data 属
方法:1、使用“new Date(year, month,0)”语句根据指定年份和月份来创建日期对象;2、使用“日期对象.getDate()”语句处理日期对象,返回指定月份的最后一天,即可知道指定月份有多少天。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008