web-component-gallery 2.2.49 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js.umd.js +1 -1
- package/lib/no-data/directive.js +16 -25
- package/package.json +1 -1
package/lib/no-data/directive.js
CHANGED
|
@@ -13,20 +13,6 @@ import NoData from './index.vue'
|
|
|
13
13
|
// <div v-no-data:暂无文件.file="list"></div>
|
|
14
14
|
// <div v-no-data:暂无图表.chart="list"></div>
|
|
15
15
|
|
|
16
|
-
// <!-- 在元素前插入占位组件,不清空原始元素 -->
|
|
17
|
-
// <div v-no-data.before="list"></div>
|
|
18
|
-
// <!-- 结合其他修饰符 -->
|
|
19
|
-
// <div v-no-data.before:暂无="list"></div>
|
|
20
|
-
// <div v-no-data.before.file="list"></div>
|
|
21
|
-
// <div v-no-data.before:暂无文件.file="list"></div>
|
|
22
|
-
|
|
23
|
-
// <!-- 清空原始元素并完全替换为占位组件 -->
|
|
24
|
-
// <div v-no-data.replace="list"></div>
|
|
25
|
-
// <!-- 结合其他修饰符 -->
|
|
26
|
-
// <div v-no-data.replace:暂无="list"></div>
|
|
27
|
-
// <div v-no-data.replace.file="list"></div>
|
|
28
|
-
// <div v-no-data.replace:暂无文件.file="list"></div>
|
|
29
|
-
|
|
30
16
|
// 判断内容是否为空
|
|
31
17
|
const isEmpty = value => {
|
|
32
18
|
if (value == null) return true // 包含 null 和 undefined
|
|
@@ -49,15 +35,9 @@ export default function(Vue) {
|
|
|
49
35
|
|
|
50
36
|
el._noDataInstance = instance
|
|
51
37
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
el.parentNode.insertBefore(instance.$el, el)
|
|
56
|
-
} else {
|
|
57
|
-
// 默认行为:清空原始元素并插入占位组件
|
|
58
|
-
el.innerHTML = ''
|
|
59
|
-
el.appendChild(instance.$el)
|
|
60
|
-
}
|
|
38
|
+
// 默认行为:隐藏原始元素并插入占位组件
|
|
39
|
+
el.style.display = 'none' // 隐藏原始元素
|
|
40
|
+
el.parentNode.insertBefore(instance.$el, el) // 在元素前插入占位组件
|
|
61
41
|
}
|
|
62
42
|
|
|
63
43
|
const removeNoDataInstance = (el) => {
|
|
@@ -71,6 +51,9 @@ export default function(Vue) {
|
|
|
71
51
|
}
|
|
72
52
|
el._noDataInstance.$destroy()
|
|
73
53
|
el._noDataInstance = null
|
|
54
|
+
|
|
55
|
+
// 显示原始元素
|
|
56
|
+
el.style.display = '' // 恢复原始元素的显示
|
|
74
57
|
}
|
|
75
58
|
}
|
|
76
59
|
|
|
@@ -78,6 +61,9 @@ export default function(Vue) {
|
|
|
78
61
|
inserted(el, binding) {
|
|
79
62
|
if (isEmpty(binding.value)) {
|
|
80
63
|
createNoDataInstance(el, binding)
|
|
64
|
+
} else {
|
|
65
|
+
// 数据存在时显示原始元素
|
|
66
|
+
el.style.display = ''
|
|
81
67
|
}
|
|
82
68
|
},
|
|
83
69
|
update(el, binding) {
|
|
@@ -91,14 +77,19 @@ export default function(Vue) {
|
|
|
91
77
|
el._noDataInstance.type = modifierType
|
|
92
78
|
|
|
93
79
|
// 如果模式改变,重新创建实例
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
const isBeforeMode = !!binding.modifiers.before
|
|
81
|
+
const isCurrentBeforeMode = el._noDataInstance.$el.parentNode !== el
|
|
82
|
+
|
|
83
|
+
if ((isBeforeMode && !isCurrentBeforeMode) ||
|
|
84
|
+
(!isBeforeMode && isCurrentBeforeMode)) {
|
|
96
85
|
removeNoDataInstance(el)
|
|
97
86
|
createNoDataInstance(el, binding)
|
|
98
87
|
}
|
|
99
88
|
}
|
|
100
89
|
} else {
|
|
90
|
+
// 数据存在时显示原始元素
|
|
101
91
|
removeNoDataInstance(el)
|
|
92
|
+
el.style.display = ''
|
|
102
93
|
}
|
|
103
94
|
}
|
|
104
95
|
},
|