Vue click outside directive.
$ npm install jy-dblclick-outside
<template>
<div>
<div v-dbl-click-outside="hide" @click="toggle">Toggle</div>
<div v-show="opened">test</div>
</div>
</template>
<script>
import DblClickOutside from 'jy-dblclick-outside'
export default {
data () {
return {
opened: false
}
},
methods: {
toggle () {
this.opened = true
},
hide () {
this.opened = false
}
},
// 自定义指令注册
directives: {
DblClickOutside
}
}
</script>