VueJS参数绑定:v-bind:href,v-on:event
时间:2017-06-28 17:16:56
收藏:0
阅读:5707
参数绑定HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue 测试实例 - 菜鸟教程(runoob.com)</title> <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script> </head> <body> <div id="app"> <pre><a v-bind:href="url">青青子衿</a></pre> </div> <script> new Vue({ el: ‘#app‘, data: { url: ‘http://www.boonya.com‘ } }) </script> </body> </html>
参数绑定效果:
事件绑定HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue 测试实例 - 菜鸟教程(runoob.com)</title> <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script> </head> <body> <div id="app"> <a v-on:click="doSomething">doSomething</a> </div> <script> new Vue({ el: ‘#app‘, data: { doSomething:function(){ alert("Do something"); } } }) </script> </body> </html>
事件绑定效果:
评论(0)