summaryrefslogtreecommitdiff
path: root/UI source code/dns_mapping_ui-master/src/directive
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
parent8165dfcc7bdb0b2e6f1c05f8e7c93553c0e7911e (diff)
upload UI source codeHEADmain
Diffstat (limited to 'UI source code/dns_mapping_ui-master/src/directive')
-rw-r--r--UI source code/dns_mapping_ui-master/src/directive/clickoutside.js50
-rw-r--r--UI source code/dns_mapping_ui-master/src/directive/idscope.js58
2 files changed, 108 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__;
+ },
+};
diff --git a/UI source code/dns_mapping_ui-master/src/directive/idscope.js b/UI source code/dns_mapping_ui-master/src/directive/idscope.js
new file mode 100644
index 0000000..7b7a821
--- /dev/null
+++ b/UI source code/dns_mapping_ui-master/src/directive/idscope.js
@@ -0,0 +1,58 @@
+import app from '../main.js'
+
+//异步写法 暂时不用
+export async function getParentAsync(context, componentPath = '') {
+ await app.$nextTick(() => {
+
+ }, 10)
+ return getParent(context, componentPath = '')
+}
+
+
+export function getParent(context, componentPath = '') {
+ var currentIndex = null;
+ var currentName = null
+ !context ? context = this : ''
+ //获取父级节点
+ var parent = context && context.$parent || null;
+ var siblings = (parent && parent.$children) || [];
+
+ currentIndex = siblings.findIndex((item, index) => {
+ return item._uid === context._uid
+ });
+ currentName = context.$options.name || 'anonymousComponent'
+
+ // var currentPath = currentName + currentIndex //加index,异步组件 会导致索引变化
+ var currentPath = currentName
+
+ componentPath = componentPath ? componentPath + '_' + currentPath : currentPath
+ if (parent) {
+ return getParent(parent, componentPath)
+ }
+ return componentPath
+}
+
+export const idscope = {
+ bind: function (el, binding, vnode) {
+ var context = vnode.context;
+ var id = el.getAttribute('id') || null;
+ // 同步写法
+ var prefix = getParent(context);
+ if (id) {
+ var scopedId = id + '-_' + prefix;
+ el.setAttribute('id', scopedId)
+
+ }
+
+ //异步写法
+ // getParentAsync(context).then((prefix) => {
+ // if (id) {
+ // var scopedId = id + '-_' + prefix;
+ // el.setAttribute('id', scopedId)
+ // }
+ // });
+ }
+}
+
+
+