diff --git a/packages/vant/src/action-sheet/README.md b/packages/vant/src/action-sheet/README.md index bcb0dbae0..3d506b090 100644 --- a/packages/vant/src/action-sheet/README.md +++ b/packages/vant/src/action-sheet/README.md @@ -223,7 +223,7 @@ export default { | default | Custom content | | description | Custom description above the options | | cancel `v3.0.10` | Custom the content of cancel button | -| action `v3.3.8` | Custom the content of option | _{ action: Action, index: number }_ | +| action `v3.3.8` | Custom the content of action | _{ action: ActionSheetAction, index: number }_ | ### Types diff --git a/packages/vant/src/action-sheet/README.zh-CN.md b/packages/vant/src/action-sheet/README.zh-CN.md index 131832cc7..a5cf0bc49 100644 --- a/packages/vant/src/action-sheet/README.zh-CN.md +++ b/packages/vant/src/action-sheet/README.zh-CN.md @@ -235,7 +235,7 @@ export default { | default | 自定义面板的展示内容 | - | | description | 自定义描述文案 | - | | cancel `v3.0.10` | 自定义取消按钮内容 | - | -| action `v3.3.8` | 自定义选项内容 | _{ action: Action, index: number }_ | +| action `v3.3.8` | 自定义选项内容 | _{ action: ActionSheetAction, index: number }_ | ### 类型定义 diff --git a/packages/vant/src/popover/Popover.tsx b/packages/vant/src/popover/Popover.tsx index b587d7387..78b10d6d9 100644 --- a/packages/vant/src/popover/Popover.tsx +++ b/packages/vant/src/popover/Popover.tsx @@ -166,8 +166,25 @@ export default defineComponent({ } }; + const renderActionContent = (action: PopoverAction, index: number) => { + if (slots.action) { + return slots.action({ action, index }); + } + + return [ + action.icon && ( + + ), +
{action.text}
, + ]; + }; + const renderAction = (action: PopoverAction, index: number) => { - const { icon, text, color, disabled, className } = action; + const { icon, color, disabled, className } = action; return (
onClickAction(action, index)} > - {icon && ( - - )} -
{text}
+ {renderActionContent(action, index)}
); }; diff --git a/packages/vant/src/popover/README.md b/packages/vant/src/popover/README.md index 84133aca9..6389becd8 100644 --- a/packages/vant/src/popover/README.md +++ b/packages/vant/src/popover/README.md @@ -250,10 +250,11 @@ export default { ### Slots -| Name | Description | -| --------- | ----------------- | -| default | Custom content | -| reference | Reference Element | +| Name | Description | SlotProps | +| --- | --- | --- | +| default | Custom content | - | +| reference | Reference Element | - | +| action `v3.3.8` | Custom the content of option | _{ action: PopoverAction, index: number }_ | ### Types diff --git a/packages/vant/src/popover/README.zh-CN.md b/packages/vant/src/popover/README.zh-CN.md index 9ab31930e..ed4a5c9e5 100644 --- a/packages/vant/src/popover/README.zh-CN.md +++ b/packages/vant/src/popover/README.zh-CN.md @@ -262,10 +262,11 @@ export default { ### Slots -| 名称 | 说明 | -| --------- | --------------------------- | -| default | 自定义菜单内容 | -| reference | 触发 Popover 显示的元素内容 | +| 名称 | 说明 | 参数 | +| --- | --- | --- | +| default | 自定义菜单内容 | - | +| reference | 触发 Popover 显示的元素内容 | - | +| action `v3.3.8` | 自定义选项内容 | _{ action: PopoverAction, index: number }_ | ### 类型定义 diff --git a/packages/vant/src/popover/demo/index.vue b/packages/vant/src/popover/demo/index.vue index 8aa0740e9..06f48db5a 100644 --- a/packages/vant/src/popover/demo/index.vue +++ b/packages/vant/src/popover/demo/index.vue @@ -1,14 +1,14 @@