vueカスタムラベル(directives)

931 ワード

  • グローバルカスタムラベルの使用(いずれのインスタンス化ラベルも使用可能)Vue.directives(「focus」,bind:function(el,binding,vnode){el.focus(})
  • プライベートカスタムラベルの使用(プライベートインスタンスラベルのみ):
  • 1.第一の書き方
    
    export default{
        data(){
            return{
            }
         },
        directives:{
            "focus":{
                bind:function(el,binding){
                    el.focus()
                }
            }
          }
        }
    }
    

    2.2つ目の書き方:
    
    export default{
        data(){
            return{
                txtInput:""
            }
        },
        directives:{
            "border":{
                bind:function(el,binding){
                    el.style.border=binding.value
                }
            }
        }
    }