element-plus
Version:
> TODO: description
18 lines (17 loc) • 443 B
JavaScript
import { watch } from 'vue';
import { on, off } from '../../utils/dom';
export default (indicator, evt, cb) => {
const prevent = (e) => {
if (cb(e)) {
e.stopImmediatePropagation();
}
};
watch(() => indicator.value, val => {
if (val) {
on(document, evt, prevent, true);
}
else {
off(document, evt, prevent, true);
}
}, { immediate: true });
};