Vue常用指令v-on:click
2017-02-13 15:27
453 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="../js/Vue.js" charset="utf-8"></script> <script type="text/javascript"> window.onload = function(){ var vm = new Vue({ el:'.box', data:{ arr:['app','orange','pare'], json:{a:'app',b:'banana',c:'ccc',d:'dog'} }, methods:{ show:function(){ alert(1); } } }); } </script> </head> <body> <div class="box"> <ul> <li v-for='(value,index) in arr'>{{value}} {{index}}</li> </ul> <hr /> <ul> <li v-for='(value,index) in json'>{{value}} {{index}}</li> </ul> <hr /> <ul> <li v-for='(k,v,index) in json'>{{k}} {{v}} {{index}}</li> </ul> <hr /> <button type="button" v-on:click='show()'>点击</button> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="../js/Vue.js" charset="utf-8"></script> <script type="text/javascript"> window.onload = function(){ var vm = new Vue({ el:'.box', data:{ arr:['app','orange','pare'], }, methods:{ show:function(){ this.arr.push('tomato'); } } }); } </script> </head> <body> <div class="box"> <button type="button" v-on:click='show()'>点击</button> <hr /> <ul> <li v-for='(value,index) in arr'>{{value}} {{index}}</li> </ul> </div> </body> </html>
相关文章推荐
- Vue.js 系列教程 2:组件,Props,Slots
- MySQL UUID函数的详解
- 浅谈require.js
- Vue常用指令v-for
- vuejs 1.x - 实例:搜索过滤
- Vue常用指令_V-model
- org.hibernate.hql.internal.ast.QuerySyntaxExceptionunexpected token: on near line 1
- Vue雏形
- Gradle for Android 第二篇( Build.gradle入门 )
- UIView的常见属性和代码创建UIButton
- String,StringBuffer与StringBuilder的区别??
- zImage和uImage等内核文件总结
- iOS图形绘制 UIBezierPath 绘制折线图、柱状图、饼形图
- ueditor(百度编辑器)的第一次使用以及关键配置
- mybatis随笔一之SqlSessionFactoryBuilder
- Ubuntu Cannot run program "../SDK/build-tools/xxx/aapt": erro = 2 No such file or directory
- break和continue区别
- 蓝牙协议的命令和事件
- 拿到贴过贴纸的UIImage
- uiautomator 2.0 dependencies