diff --git a/src/guide/guide.vue b/src/guide/guide.vue index 72ffe094c..6b4829867 100644 --- a/src/guide/guide.vue +++ b/src/guide/guide.vue @@ -92,7 +92,7 @@ import TPopover, { PopoverProps } from '../popover'; import TPopup, { PopupProps } from '../popup'; import TButton, { ButtonProps } from '../button'; import config from '../config'; -import { useVModel, TNode, renderTNode } from '../shared'; +import { useVModel, TNode } from '../shared'; import { addClass, getWindowScroll, removeClass } from '../shared/dom'; import setStyle from '../_common/js/utils/set-style'; import guideProps from './props'; @@ -278,9 +278,16 @@ export default defineComponent({ total: stepsTotal.value, current: innerCurrent.value, }; - const node = - renderTNode(getCurrentInstance(), 'counter', { params }) || ` (${innerCurrent.value + 1}/${stepsTotal.value})`; - return node; + let renderCounter: any = null; + const { counter } = props; + if (isFunction(counter)) { + renderCounter = counter(h, params); + } else if (context.slots.counter) { + renderCounter = context.slots.counter(hWithParams(params)); + } else if (counter) { + renderCounter = h(counter, params); + } + return renderCounter || ` (${innerCurrent.value + 1}/${stepsTotal.value})`; }); const isLast = computed(() => innerCurrent.value === stepsTotal.value - 1); diff --git a/src/shared/render.ts b/src/shared/render.ts index 0e9798086..3f3f2bba8 100644 --- a/src/shared/render.ts +++ b/src/shared/render.ts @@ -33,11 +33,11 @@ export const renderTNode = ( // 同名优先处理插槽 if (instance.slots[name]) { - return instance.slots[name]?.(params); + return instance.slots[name]?.call(params); } if (propsNode === true && defaultNode) { - return instance.slots[name] ? instance.slots[name]?.(params) : defaultNode; + return instance.slots[name] ? instance.slots[name]?.call(params) : defaultNode; } if (typeof propsNode === 'function') { @@ -48,7 +48,7 @@ export const renderTNode = ( } const isPropsEmpty = [undefined, params, ''].includes(propsNode); - if (isPropsEmpty && instance.slots[name]) return instance.slots[name]?.(params); + if (isPropsEmpty && instance.slots[name]) return instance.slots[name]?.call(params); return propsNode; };