<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title> vue点击按钮文字增删</title> <style> *{ margin: 0; padding: 0; list-style: none; } </style> </head> <body> <div> <input type="text" v-model="text"> <button @click="add">add</button> <button @click="clear">remove</button> <button @click="clean">remove one</button> <div v-for="x in arr">{{x}}</div> </div> <div> <span v-bind:title="message"> 鼠标悬停几秒钟查看此处动态绑定的提示信息! </span> </div> </body> <script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script> <script> var app2 = new Vue({ el: '#app-2', data: { message: '页面加载于 ' + new Date().toLocaleString() } }); const app=new Vue({ el:"#app", data:{ arr:[], text:"" }, methods:{ add(){ this.arr.push(this.text); }, clear(){ this.arr=[] }, clean(){ this.arr.pop(); } } }) </script> </html>
vue input实现点击按钮文字增删功能示例
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/51809f39659e8099b865157adfc3838c.html