vue实现记事本功能
更新时间:2021年06月24日 14:58:12 作者:zy6648
这篇文章主要为大家详细介绍了vue实现记事本功能,记事本可以进行添加删除事件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了vue实现记事本功能的具体代码,供大家参考,具体内容如下
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>记事本</title> <meta http-equiv="X-UA-Compatible" content="IE-edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="stylesheet" type="text/css" href="./bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="external nofollow" > <script type="text/javascript" src="./vue.js"></script> </head> <body> <div class="container" id="app"> <div class="row"> <div class="col-md-6 "> <h1 class="text-succeed">{{title}}</h1> <input type="text" name="text" placeholder="填写事务" v-model="newThing"/> <button type="button" class="btn text-active" v-on:click="addThing" v-on:keyup.enter="addThing">添加事务</button> </div> </div> <div class="row"> <div class="col-md-3 "> <div class="thumbnail"> <ul> <li v-for="(item,index) in things" class="text-center text-info" v-show="item.show">{{item.thing}} <button class="btn btn-default bg-info" v-on:click="removeThing(index)" v-model="index">删除</button></li> </ul> </div> </div> </div> </div> </body> <script type="text/javascript"> var vue=new Vue({ el:'#app', data:{ title: '记事本', things:[ { thing:'', show:false } ], newThing:'', message:'待填写的事务为空!!' }, methods:{ addThing:function(){ if(this.newThing){ this.things.splice(0,0,{ thing:this.newThing, show:true }); this.newThing='' }else{ alert(this.message) } }, removeThing:function(index){ this.things[index].show=false } } }); </script> </html>
效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
vue动态路由加载时出现Cannot find module xxx问题
这篇文章主要介绍了vue动态路由加载时出现Cannot find module xxx问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-01-01vue中el-date-picker type=daterange日期清空时不回显的解决
这篇文章主要介绍了vue中el-date-picker type=daterange日期清空时不回显的解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-07-07vue.js中created()与activated()的个人使用解读
这篇文章主要介绍了vue.js中created()与activated()的个人使用,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-07-07vue+vuex+axio从后台获取数据存入vuex实现组件之间共享数据
这篇文章主要介绍了vue+vuex+axio从后台获取数据存入vuex,组件之间共享数据,非常具有实用价值,需要的朋友可以参考下2017-04-04
最新评论