vue自定义指令?

2020-06-11 20:10发布

3条回答
web-天佑
2020-07-17 16:18

自定义指令:使用Vue.directive(id,definition)注册全局自定义指令,使用组件的directives选项注册局部自定义指令。


// 注册一个全局自定义指令 `v-focus`Vue.directive('focus', {  // 当被绑定的元素插入到 DOM 中时……  inserted: function (el) {    // 聚焦元素    el.focus()  } })

一周热门 更多>