feat(components): [cascader] add prefix slot (#19631)

* feat(components): [cascader] add prefix slot

* docs(components): [cascader] add preview slot

* Revert "docs(components): [cascader] add preview slot"

This reverts commit 1a40ca13ea.

* docs(components): [cascader] revert for typo

* fix(components): do not render prefix if prefix slot is not used

* docs(components): [cascader] prefix version number added

Co-authored-by: btea <2356281422@qq.com>

* docs(components): [cascader] format docs

---------

Co-authored-by: btea <2356281422@qq.com>
This commit is contained in:
David Kitano 2025-01-18 09:23:33 +08:00 committed by GitHub
parent add84b5694
commit 40a616ea1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 4 deletions

View File

@ -175,10 +175,11 @@ cascader/panel
### Cascader Slots
| Name | Description | Scope |
| ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------- |
| default | the custom content of cascader node, which are current Node object and node data respectively. | ^[object]`{ node: any, data: any }` |
| empty | content when there is no matched options. | — |
| Name | Description | Scope |
| --------------- | ---------------------------------------------------------------------------------------------- | ----------------------------------- |
| default | the custom content of cascader node, which are current Node object and node data respectively. | ^[object]`{ node: any, data: any }` |
| empty | content when there is no matched options. | — |
| prefix ^(2.9.4) | content as Input prefix | — |
### Cascader Exposes

View File

@ -559,4 +559,19 @@ describe('Cascader.vue', () => {
expect(emptySlotEl?.textContent).toBe('-=-empty-=-no-data')
})
})
describe('render prefix slot', () => {
it('correct render prefix slot', async () => {
_mount(() => (
<Cascader>
{{
prefix: () => <div>-=-prefix-=-</div>,
}}
</Cascader>
))
const prefixSlotEl = document.querySelector('.el-input__prefix-inner')
expect(prefixSlotEl?.textContent).toBe('-=-prefix-=-')
})
})
})

View File

@ -42,6 +42,9 @@
@blur="handleBlur"
@input="handleInput"
>
<template v-if="$slots.prefix" #prefix>
<slot name="prefix" />
</template>
<template #suffix>
<el-icon
v-if="clearBtnVisible"