Skip to content

Commit 4b7c6ac

Browse files
trry-hubshizhu
and
shizhu
authored
feat: TourStep support fn children (#7628)
* Fix: [修复自定义按钮无渲染] * refactor(完善 Tour 自定义按钮代码健壮性): 🦄 --------- Co-authored-by: shizhu <[email protected]>
1 parent 208b8d3 commit 4b7c6ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/tour/panelRender.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { computed, defineComponent, toRefs } from 'vue';
22
import classNames from '../_util/classNames';
3+
import { isFunction } from '../_util/util';
34
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
45
import { tourStepProps } from './interface';
56
import type { TourBtnProps } from './interface';
@@ -119,7 +120,9 @@ const panelRender = defineComponent({
119120
size="small"
120121
class={classNames(`${prefixCls}-prev-btn`, prevButtonProps?.className)}
121122
>
122-
{prevButtonProps?.children ?? contextLocale.Previous}
123+
{isFunction(prevButtonProps?.children)
124+
? prevButtonProps.children()
125+
: prevButtonProps?.children ?? contextLocale.Previous}
123126
</Button>
124127
) : null}
125128
<Button
@@ -129,8 +132,11 @@ const panelRender = defineComponent({
129132
size="small"
130133
class={classNames(`${prefixCls}-next-btn`, nextButtonProps?.className)}
131134
>
132-
{nextButtonProps?.children ??
133-
(isLastStep.value ? contextLocale.Finish : contextLocale.Next)}
135+
{isFunction(nextButtonProps?.children)
136+
? nextButtonProps?.children()
137+
: isLastStep.value
138+
? contextLocale.Finish
139+
: contextLocale.Next}
134140
</Button>
135141
</div>
136142
</div>

0 commit comments

Comments
 (0)