承接国内外服务器租用托管、定制开发、网站代运营、网站seo优化托管接单、网站代更新,新老站点皆可!!咨询QQ:3787320601

vue自定义指令的有什么方法

管理员 2023-03-25 09:44:31 互联网圈 68 ℃ 0 评论 1995字 收藏

vue自定义指令的有甚么方法

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

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

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

vue自定义指令语法:

Vue.directive(id, definition)

1.自定义全局指令

Vue.directive('focus', {

     bind: function (el) { 

         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';

    }

}


文章来源:丸子建站

文章标题:vue自定义指令的有什么方法

https://www.wanzijz.com/view/3451.html

TAG: vue

相关文章

Related articles

X

截屏,微信识别二维码

微信号:weimawl

(点击微信号复制,添加好友)

打开微信