diff --git a/src/popover/Popover.tsx b/src/popover/Popover.tsx index fb9149a01..688b7b69d 100644 --- a/src/popover/Popover.tsx +++ b/src/popover/Popover.tsx @@ -101,6 +101,7 @@ export default defineComponent({ type: [String, Object] as PropType, default: 'body', }, + iconPrefix: String, }, emits: ['select', 'touchstart', 'update:show'], @@ -190,7 +191,13 @@ export default defineComponent({ style={{ color }} onClick={() => onClickAction(action, index)} > - {icon && } + {icon && ( + + )}
{text}
); diff --git a/src/popover/README.md b/src/popover/README.md index 73949c501..04f2d411d 100644 --- a/src/popover/README.md +++ b/src/popover/README.md @@ -224,6 +224,7 @@ export default { | close-on-click-outside | Whether to close when clicking outside | _boolean_ | `true` | | close-on-click-overlay `v3.0.10` | Whether to close when clicking overlay | _boolean_ | `true` | | teleport | Return the mount node for Popover | _string \| Element_ | `body` | +| icon-prefix | Icon className prefix | _string_ | `van-icon` | ### Data Structure of Action diff --git a/src/popover/README.zh-CN.md b/src/popover/README.zh-CN.md index aca4bc96d..ca559bc24 100644 --- a/src/popover/README.zh-CN.md +++ b/src/popover/README.zh-CN.md @@ -234,6 +234,7 @@ export default { | close-on-click-outside | 是否在点击外部元素后关闭菜单 | _boolean_ | `true` | | close-on-click-overlay `v3.0.10` | 是否在点击遮罩层后关闭菜单 | _boolean_ | `true` | | teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` | +| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | ### Action 数据结构 diff --git a/src/popover/test/__snapshots__/index.spec.tsx.snap b/src/popover/test/__snapshots__/index.spec.tsx.snap index 90adbf6e6..2c1910f27 100644 --- a/src/popover/test/__snapshots__/index.spec.tsx.snap +++ b/src/popover/test/__snapshots__/index.spec.tsx.snap @@ -10,6 +10,11 @@ exports[`should allow to custom the className of action 1`] = ` `; +exports[`should change icon class prefix when using icon-prefix prop 1`] = ` + + +`; + exports[`should locate to reference element when showed 1`] = ` diff --git a/src/popover/test/index.spec.tsx b/src/popover/test/index.spec.tsx index 7f41d2f19..a22d59b48 100644 --- a/src/popover/test/index.spec.tsx +++ b/src/popover/test/index.spec.tsx @@ -187,3 +187,15 @@ test('should not close Popover when outside is clicked and close-on-click-outsid trigger(document.body, 'touchstart'); expect(wrapper.emitted('update:show')).toBeFalsy(); }); + +test('should change icon class prefix when using icon-prefix prop', () => { + const wrapper = mount(Popover, { + props: { + show: true, + icon: 'success', + iconPrefix: 'my-icon', + }, + }); + + expect(wrapper.html()).toMatchSnapshot(); +});