Vue.directive('click-outside', {
priority: 700,
bind () {
let self = this
this.event = function (event) {
self.vm.$emit(self.expression,event)
}
this.el.addEventListener('click', this.stopProp)
document.body.addEventListener('click',this.event)
},
unbind() {
this.el.removeEventListener('click', this.stopProp)
document.body.removeEventListener('click',this.event)
},
stopProp(event) {event.stopPropagation() }
})
<div v-click-outside="methodName"></div>
let columns = [
{ name: "name", label: "Name", width: '100' },
//...
]
obj.test();