cloud-web-corejs 1.1.0-dev.89 → 1.1.0-dev.90

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.1.0-dev.89",
4
+ "version": "1.1.0-dev.90",
5
5
  "scripts": {
6
6
  "build:ace-resources": "node build/build-ace-resources.js",
7
7
  "build:tinymce-resources": "node build/build-tinymce-resources.js",
@@ -26,6 +26,18 @@ let configUtil = {
26
26
  });
27
27
  },
28
28
  };
29
+ // 遮罩只能挂到真正的父节点上。Vue 注释占位、组件实例、选择器字符串都没有 append,
30
+ // 直接调用会在请求发出前抛错,并被错误拦截器弹成「e.loadingTarget.append is not a function」。
31
+ function resolveLoadingTarget(target) {
32
+ if (!target) return null;
33
+ if (target._isVue && target.$el) target = target.$el;
34
+ if (typeof target === "string" && typeof document !== "undefined") {
35
+ target = document.querySelector(target);
36
+ }
37
+ if (target && typeof target.append === "function") return target;
38
+ return null;
39
+ }
40
+
29
41
  let service;
30
42
 
31
43
  // create an axios instance
@@ -161,6 +173,10 @@ service.interceptors.request.use(
161
173
  applyAesBody(config);
162
174
  }
163
175
 
176
+ if (config.loadingTarget) {
177
+ config.loadingTarget = resolveLoadingTarget(config.loadingTarget);
178
+ }
179
+
164
180
  if (config.modal !== false && config.loadingTarget) {
165
181
  let zIndex = PopupManager.nextZIndex();
166
182
  let pd = document.createElement("div");
package/src/utils/vab.js CHANGED
@@ -218,7 +218,13 @@ install = (Vue, opts = {}) => {
218
218
  /**http请求*/
219
219
  let $http = async function (option) {
220
220
  option = option || {};
221
- if (!option.loadingTarget && this.$el) {
221
+ // 根节点 v-if 为 false 时 $el 是注释占位,没有 append。传进去会在请求发出前抛错。
222
+ if (
223
+ !option.loadingTarget &&
224
+ this.$el &&
225
+ this.$el.nodeType === 1 &&
226
+ typeof this.$el.append === "function"
227
+ ) {
222
228
  option.loadingTarget = this.$el;
223
229
  }
224
230
  if (!option.vueTarget) {