summaryrefslogtreecommitdiff
path: root/UI source code/dns_mapping_ui-master/src/directive/clickoutside.js
diff options
context:
space:
mode:
authorunknown <[email protected]>2022-06-24 17:11:23 +0800
committerunknown <[email protected]>2022-06-24 17:11:23 +0800
commit8565e1bb597b481447d33bac6d8c48c2c45215de (patch)
treea4f10c8f7f85a1a8b5c947f7d0d2f967d808a9c4 /UI source code/dns_mapping_ui-master/src/directive/clickoutside.js
parent8165dfcc7bdb0b2e6f1c05f8e7c93553c0e7911e (diff)
upload UI source codeHEADmain
Diffstat (limited to 'UI source code/dns_mapping_ui-master/src/directive/clickoutside.js')
-rw-r--r--UI source code/dns_mapping_ui-master/src/directive/clickoutside.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/UI source code/dns_mapping_ui-master/src/directive/clickoutside.js b/UI source code/dns_mapping_ui-master/src/directive/clickoutside.js
new file mode 100644
index 0000000..6472bcb
--- /dev/null
+++ b/UI source code/dns_mapping_ui-master/src/directive/clickoutside.js
@@ -0,0 +1,50 @@
+export const clickoutside = {
+ // 初始化指令
+ bind(el, binding, vnode) {
+ function documentHandler(e) {
+ //这里面执行的是objec ip的代码,需要修改提前说一下
+ if (binding.expression == "inputHide") {
+ if (el.parentNode.parentNode.parentNode.contains(e.target.form)) {
+ return false;
+ }
+ // // 这里判断点击的元素是否是本身,是本身,则返回
+ } else if (el.contains(e.target)) {
+ return false;
+ }
+ // // 这里判断点击的元素是否是本身,是本身,则返回
+ // console.log(el.parentNode.parentNode.parentNode.contains(e.target.form),'form');
+ // // console.log(el.parentNode.parentNode.parentNode,'父亲');
+ // console.log(binding,'本身');
+
+ // if (el.contains(e.target)) {
+
+ // return false;
+ // }
+ // 判断指令中是否绑定了函数
+
+ if (binding.expression) {
+ // 如果绑定了函数 则调用那个函数,此处binding.value就是handleClose方法
+ if (binding.arg) {
+ if (typeof binding.arg == 'object') {
+ binding.value(binding.arg);
+ } else {
+ binding.value(e, binding.arg);
+ }
+ } else {
+
+ binding.value(e);
+ }
+
+ }
+ }
+ // 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
+ el.__vueClickOutside__ = documentHandler;
+ document.addEventListener('click', documentHandler);
+ },
+ unbind(el, binding) {
+
+ // 解除事件监听
+ document.removeEventListener('click', el.__vueClickOutside__);
+ delete el.__vueClickOutside__;
+ },
+};