欢迎光临
我们一直在努力

vue自定义指令的方法有哪些

在vue中自定义指令的方法有:语法:Vue.directive(id, definition);1.自定义全局指令;2.自定义私有指令;

在vue中自定义指令的方法有以下两种

vue自定义指令语法:

Vue.directive(id, definition)

1.自定义全局指令

Vue.directive('focus', {

     bind: function (el) { 

  &vps云服务器nbsp;      el.focus()

     },

     inserted: function (el) { 

         el.focus()

     },

     updated: function () { 

     }

 });

2.自定义私有指令

directives: {

    'fontweight': {

        bind: function (el, bingding) {

            el.style.fontWeight = bingding.value;

        }

    },

    'fontsize': function (el, bingding) { 

        el.style.fontSize = parseInt(bingding.value) + 'px';

    }

}

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。