1.在src下创建directive文件夹
index.js
import directives from './directives'
const importDirective = Vue => {
Object.keys(directives).forEach(key => {
Vue.directive(key, directives[key])
})
}
export default importDirective
directives.js
import draggable from './module/draggable'
const directives = {
draggable
}
export default directives
module文件夹下写各种指令
draggable.js–拖拽指令
import {
on } from '@/libs/dom'
/**
* 拖拽指令 v-draggable="options"
* options &