Skip to content

fix(cascader): fix When using slots in cascader-panel, the mf template will error #3537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/renderless/src/cascader-node/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const renderless = (
inActivePath: computed(() => api.isInPath(parent.state.activePath)),
inCheckedPath: computed(() => api.comptCheckPath()),
value: computed(() => props.node.getValueByOption()),
// 仅 mf 用到nodeLabel
nodeLabel: computed(() => {
return parent.state.renderLabelFn
? parent.state.renderLabelFn({ node: props.node, data: props.node.data })
Expand Down
17 changes: 15 additions & 2 deletions packages/vue/src/cascader-node/src/mobile-first.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
)
"
>
<span :class="[node ? gcls('cascader-node__label_disabled') : '']">{{ state.nodeLabel }}</span>
<span v-if="typeof state.nodeLabel === 'string'" :class="[node ? gcls('cascader-node__label_disabled') : '']">
{{ state.nodeLabel }}
</span>
<span v-else :class="[node ? gcls('cascader-node__label_disabled') : '']">
<render-node-label :vnode="state.nodeLabel" />
</span>
<icon-loading v-if="node.loading" :class="gcls('cascader-node__postfix')"></icon-loading>
<icon-chevron-right
v-else-if="!state.isLeaf"
Expand All @@ -43,7 +48,15 @@ export default defineComponent({
name: $prefix + 'CascaderNode',
components: {
IconLoading: IconLoading(),
IconChevronRight: IconChevronRight()
IconChevronRight: IconChevronRight(),
RenderNodeLabel: {
name: 'AnyNode',
functional: true,
props: ['vnode'],
render(h, ctx) {
return h.vnode || ctx.props?.vnode // 兼容vue2,3的写法
}
}
},
inheritAttrs: false,
emits: ['expand', 'update:modelValue', 'expand-change', 'active-item-change', 'change'],
Expand Down
1 change: 1 addition & 0 deletions packages/vue/src/cascader-node/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default defineComponent({

const vnode = render ? render({ node, data: node.data }) : null

// 可用 state.nodeLabel 简化
return <span class="tiny-cascader-node__label">{vnode || node.label}</span>
}

Expand Down
Loading