Custom command ---- focus events gets focus

 <input type="text" class="form-control" v-model="keywords" id="search" v-focus > 
  / * Use Vue.directiive () global instructions defined 
        wherein: Parameter 1: command name, defined when one of the names for the prefix instruction does not require additional v-, v- but must be added at the time of call 
              parameters 2 : is an object, in this object, there are some instructions related functions, these functions may be at a particular stage, while executing the operation 
        * / 
        
        Vue.directive ( 'Focus', { 
            // note that in each function, the first el parameter will always be bound express instruction of which element, this is el js object element   
            bind: function (el) {// whenever the time is bound to command the elements will be executed immediately, only once 
                // in the element binding instruction time, not to insert into the DOM, this time calling focus method does not work because this element is only after the insertion of DOM to get the focus.. 

            }, 
            inserted the: function (EL) {// element into DOM in time, will perform inserted function, trigger a 
                el.focus () 
            } 
            updated (EL) {// when VNode updated, will perform updated, may trigger several times 
                
            } 
        })

  

Guess you like

Origin www.cnblogs.com/fdxjava/p/11498942.html