<input type="text" v-model="msg">
<button v-on:click="showTitle(msg, $event, 'hello')">btn</button>
<button v-on:click="showTitle">btn2</button>
<h1>{{title}}</h1>
var app = new Vue({
el: '#app',
data: {
title: '',
msg: ''
},
methods: {
// 属性名称表示回调函数的名称
showTitle: function () {
// console.log(this)
// console.log(arguments) 传的参数都能访问到 msg, $event, 'hello'
// 通过this访问vue实例化对象上的其他属性和方法。Data.title data.aa
this.title = '快乐大本营';
},
aa: function () {
}
}
})总结
以上所述是小编给大家介绍的Vue的常用指令v-if, v-for, v-show,v-else, v-bind, v-on ,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!










