Jelajahi Sumber

perf(components): 优化 UseGuidance 组件,子步骤可以自定义内容偏移的值

wangcong 3 bulan lalu
induk
melakukan
4c725e9674
2 mengubah file dengan 4 tambahan dan 1 penghapusan
  1. 3 1
      src/layout/UseGuidance.vue
  2. 1 0
      src/types/index.ts

+ 3 - 1
src/layout/UseGuidance.vue

@@ -34,8 +34,10 @@ const currentComponent = computed<Component>(() => {
 });
 
 const contentStyle = computed<CSSProperties>(() => {
+  const contentOffset = props.steps[current.value].contentOffset ?? props.contentOffset;
+
   return {
-    paddingLeft: addUnit(props.contentOffset || 312),
+    paddingLeft: addUnit(contentOffset ?? 312),
   };
 });
 

+ 1 - 0
src/types/index.ts

@@ -4,4 +4,5 @@ import type { StepProps } from 'ant-design-vue';
 export interface UseGuideStepItem extends StepProps {
   title: string;
   component: Component;
+  contentOffset?: number;
 }