首页 > 代码库 > VueJS参数绑定:v-bind:href,v-on:event

VueJS参数绑定:v-bind:href,v-on:event

参数绑定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>

事件绑定效果:
技术分享

 

VueJS参数绑定:v-bind:href,v-on:event