Vue.js

过滤器

只能应用于插值表达式和v-bind表达式

全局定义语法

定义
Vue.filter('过滤器的名称',function(数据名称){return})

调用
{{ 数据名称 | 过滤器名称 }}  支持多个过滤器同时调用

私有定义语法

定义 - 在 vm 实例中
filters{过滤器的名称:function(数据名称){return}

调用
{{ 数据名称 | 过滤器名称 }}  支持多个过滤器同时调用

自定义按键修饰符

.enter .tab .delete .esc .space @click.enter
js按键对应编码@click.13

全局

Vue.config.keyCodes.按键名 = js按键对应编码

自定义指令

全局

Vue.directive('指令名称',{指令处理函数/对象})
Vue.directive('指令名称',{
//在每个函数 第一个参数永远是el,这个el是原生js对象 没有插入到dom中
bind:function(el,binding){el.xxx } //立即执行且执行一次 //样式指令
inserted:function(el,binding){el.xx()} //插入dom 会执行此函数 只执行一次 //行为指令
updated:function(el,binding){} //当组件更新会 执行此函数 可能会触发多次
})

私有

directives:{
'指令名称':{
bind:function(el,binding){}

inserted:function(el,binding){()}

updated:function(el,binding){} 

}
}

简写

directives:{
'指令名称':{
function(el,binding){}
function(el,binding){} 
}
} //等同于 bind updated

你可能感兴趣的:(Vue.js)