From 9ca80322d0c83beb61af63822b8ee9ea80f3f33d Mon Sep 17 00:00:00 2001 From: Timi Date: Sat, 12 Jul 2025 00:59:39 +0800 Subject: [PATCH] add margin attr for Loading component --- src/components/loading/index.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/loading/index.vue b/src/components/loading/index.vue index 56a8bb6..5cfbb72 100644 --- a/src/components/loading/index.vue +++ b/src/components/loading/index.vue @@ -24,14 +24,16 @@ const props = withDefaults(defineProps<{ showOn?: boolean; size?: number; filled?: boolean; + margin?: string | number; }>(), { tips: "加载中..", delay: 260, showOn: true, size: 24, - filled: false + filled: false, + margin: 0 }); -const { tips, delay, showOn, size, filled } = toRefs(props); +const { tips, delay, showOn, size, filled, margin } = toRefs(props); // ---------- 尺寸参数 ---------- @@ -40,10 +42,12 @@ const style = computed(() => { const height = Math.round(base); const width = Math.round(base * (8 / 24)); const gap = Math.round(base * (3 / 24)); + const marginValue = typeof margin.value === "string" ? margin.value : `${margin.value}px`; return { "--loading-height": `${height}px`, "--rect-width": `${width}px`, - "--rect-gap": `${gap}px` + "--rect-gap": `${gap}px`, + "margin": marginValue }; });