当一个页面中有多个组件时,若是组件中的数据不在函数中定义,更改一个组件中的数据可能会形成其余组件的数据一块儿更改html
v-on:click
v-bind:[ishref]
当ishref值为href时,等价于v-bind:href
动态参数解析为字符串,不支持空格和大写 当动态参数的值为null时表示移除该参数<button v-on:click="warn('Form cannot be submitted yet.', $event)">
Submit
</button>
methods: {
warn: function (message, event) {
// 如今咱们能够访问原生事件对象
if (event) event.preventDefault()
alert(message)
}
}
复制代码
<span v-if="value === a">a</span>
<span v-else-if="value === b">b</span>
<span v-else>c</span> 复制代码
绑定classajax
:class="['类名',类名]"
:class="{类名:true,类名:false}"复制代码
:style="{height:100px,width:100px}"
:style="[{height:100px},{width:100px}]"复制代码
<span v-for="(item,i) in Array" :key="i/ID">复制代码
<span v-for="(value,key,index) in Array" :key="i/ID">复制代码
Vue.directive('指令名',{inserted:function(){}})复制代码
new Vue({
directives:{
'指令名':{
inserted:function(){} } }
})复制代码
Vue.onfig.keyCodes.f1=112复制代码
Vue.keyup.exact.ctrl="submit" 只按下ctrl时触发 复制代码
data中的数据须要定义较为复杂的语法时,将语法定义到computered中的,data中不要定义复杂的语法数组
new Vue ({
computered:{
}
})复制代码
当data的数据须要进行异步操做时,使用侦听器监听data的数据变化,当数据发生改变时触发侦听器中的函数浏览器
new Vue({
watch:{
}
})复制代码
{{data | 过滤器名字}}
Vue.filter() 参数1:过滤器名字 参数2.回调函数(须要return值)复制代码
new Vue({
filters:{
'过滤器':function
}
})复制代码