Vue基础之自定义指令

 1 <!-- 自定义指令 -->
 2 <input type="text" class="form-control" v-model="keywords" v-focus>
 3 
 4 //定义全局指令
 5 
 6         Vue.directive('focus',{
 7             bind:function(el){
 8                 
 9             },
10             inserted:function(el){
11                 el.focus()//可以使用Dom方法
12             },
13             update:function(){}
14         })

猜你喜欢

转载自www.cnblogs.com/peterWXM/p/12625758.html