Vue2 自定义指令
Vue2 自定义指令
私有自定义指令
只能在定义自定义指令的组件中使用
1 | <template> |
bind 函数和 update 函数不冲突,并且互补
简写
当 bind 函数和 update 函数内容是相同的时候可以使用简写
1 | <script> |
全局自定义指令
在所有的组件中都可以使用
1 | Vue.directive('color', (el,binding) => { |
第一个参数是自定义指令名称,第二个参数是自定义指令的行为
自定义指令需要绑定的元素在页面上插入时,才会执行
-
感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 View Room
评论