Skip to content

Commit

Permalink
feat: TourStep support fn children (vueComponent#7628)
Browse files Browse the repository at this point in the history
* Fix: [修复自定义按钮无渲染]

* refactor(完善 Tour 自定义按钮代码健壮性): 🦄

---------

Co-authored-by: shizhu <shizhu@yaomaitong.cn>
  • Loading branch information
trry-hub and shizhu authored Jun 10, 2024
1 parent 208b8d3 commit 4b7c6ac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/tour/panelRender.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { computed, defineComponent, toRefs } from 'vue';
import classNames from '../_util/classNames';
import { isFunction } from '../_util/util';
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
import { tourStepProps } from './interface';
import type { TourBtnProps } from './interface';
Expand Down Expand Up @@ -119,7 +120,9 @@ const panelRender = defineComponent({
size="small"
class={classNames(`${prefixCls}-prev-btn`, prevButtonProps?.className)}
>
{prevButtonProps?.children ?? contextLocale.Previous}
{isFunction(prevButtonProps?.children)
? prevButtonProps.children()
: prevButtonProps?.children ?? contextLocale.Previous}
</Button>
) : null}
<Button
Expand All @@ -129,8 +132,11 @@ const panelRender = defineComponent({
size="small"
class={classNames(`${prefixCls}-next-btn`, nextButtonProps?.className)}
>
{nextButtonProps?.children ??
(isLastStep.value ? contextLocale.Finish : contextLocale.Next)}
{isFunction(nextButtonProps?.children)
? nextButtonProps?.children()
: isLastStep.value
? contextLocale.Finish
: contextLocale.Next}
</Button>
</div>
</div>
Expand Down

0 comments on commit 4b7c6ac

Please sign in to comment.