support Poptip & clickoutside

support Poptip & clickoutside
This commit is contained in:
梁灏 2017-03-03 15:19:21 +08:00
parent d6f644e1d9
commit 79288d43dd
11 changed files with 72 additions and 49 deletions

View file

@ -1,19 +1,21 @@
export default {
bind () {
this.documentHandler = (e) => {
if (this.el.contains(e.target)) {
bind (el, binding, vnode) {
function documentHandler (e) {
if (el.contains(e.target)) {
return false;
}
if (this.expression) {
this.vm[this.expression]();
if (binding.expression) {
binding.value(e);
}
};
document.addEventListener('click', this.documentHandler);
}
el.__vueClickOutside__ = documentHandler;
document.addEventListener('click', documentHandler);
},
update () {
},
unbind () {
document.removeEventListener('click', this.documentHandler);
unbind (el, binding) {
document.removeEventListener('click', el.__vueClickOutside__);
delete el.__vueClickOutside__;
}
};