From 00ddda193736f62a0750e20738293f307b3082b9 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Tue, 22 Jul 2025 21:37:17 +0800 Subject: [PATCH] feat: dict demo --- .../src/components/dict/src/index.vue | 16 ++- .../src/components/dict/src/type.d.ts | 4 +- .../src/views/演示使用自行删除/dict/index.vue | 117 ++++++++++++++++++ 3 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 apps/web-antd/src/views/演示使用自行删除/dict/index.vue diff --git a/apps/web-antd/src/components/dict/src/index.vue b/apps/web-antd/src/components/dict/src/index.vue index 8078f095..160c1ecc 100644 --- a/apps/web-antd/src/components/dict/src/index.vue +++ b/apps/web-antd/src/components/dict/src/index.vue @@ -6,7 +6,7 @@ import type { DictFallback } from './type'; import type { DictData } from '#/api/system/dict/dict-data-model'; -import { computed, defineComponent, h } from 'vue'; +import { computed, defineComponent, h, isVNode } from 'vue'; import { Spin, Tag } from 'ant-design-vue'; import { isFunction, isString } from 'lodash-es'; @@ -83,7 +83,7 @@ export default defineComponent({ }; }, render() { - const { color, cssClass, label, loading, fallback, value } = this; + const { color, cssClass, label, loading, fallback, value, $slots } = this; /** * 字典list为0 加载中 @@ -101,9 +101,17 @@ export default defineComponent({ * 可为string/Vnode */ if (label === null) { - // VNode + // 优先返回slot + if ($slots.fallback) { + return $slots.fallback(value); + } + // VNode / String if (isFunction(fallback)) { - return h(fallback(value)); + const rValue = fallback(value); + if (isVNode(rValue)) { + return h(rValue); + } + return
+ 你可以简单理解为getDictOptions是以下代码的快捷方式(还包括对并发和缓存的处理) +
+