@hlw-uni/mp-vue 1.1.16 → 1.1.17

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "description": "hlw-uni Vue 组件库 — 供小程序业务方使用的 UI 组件集合",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  </template>
32
32
 
33
33
  <script setup lang="ts">
34
- import { computed, useSlots, Comment } from "vue";
34
+ import { computed, useSlots } from "vue";
35
35
 
36
36
  type ButtonType =
37
37
  | "primary"
@@ -90,9 +90,16 @@ const hasContent = computed(() => {
90
90
  const nodes = slots.default?.();
91
91
  if (!nodes || nodes.length === 0) return false;
92
92
  return nodes.some((n) => {
93
- if (n.type === Comment) return false;
93
+ const type = n.type;
94
+ // 普通元素 / 组件节点
95
+ if (typeof type !== "symbol") return true;
96
+ // symbol 类型的节点(Comment / Fragment / Text),通过 description 判断
97
+ const desc = String((type as unknown as { description?: string }).description || "");
98
+ if (desc.includes("Comment") || desc === "v-cmt") return false;
99
+ // Text / Fragment 节点:有实际 children 才算有内容
94
100
  if (typeof n.children === "string") return n.children.trim() !== "";
95
- return true;
101
+ if (Array.isArray(n.children)) return n.children.length > 0;
102
+ return false;
96
103
  });
97
104
  });
98
105