diff --git a/src/address-list/AddressList.tsx b/src/address-list/AddressList.tsx index af588dc49..3d4aa0332 100644 --- a/src/address-list/AddressList.tsx +++ b/src/address-list/AddressList.tsx @@ -68,6 +68,7 @@ export default defineComponent({ { + if (slots.tag) { + return slots.tag({ ...props.address }); + } if (props.address.isDefault && props.defaultTagText) { return ( diff --git a/src/address-list/README.md b/src/address-list/README.md index 6f14b4a6c..8b951650b 100644 --- a/src/address-list/README.md +++ b/src/address-list/README.md @@ -108,11 +108,12 @@ export default { ### Slots -| Name | Description | SlotProps | -| ----------- | ------------------------------ | --------------- | -| default | Custom content after list | - | -| top | Custom content before list | - | -| item-bottom | Custom content after list item | _item: Address_ | +| Name | Description | SlotProps | +| ----------- | --------------------------------- | --------------- | +| default | Custom content after list | - | +| top | Custom content before list | - | +| item-bottom | Custom content after list item | _item: Address_ | +| tag | Custom tag conetent for list item | _item: Address_ | ### Less Variables diff --git a/src/address-list/README.zh-CN.md b/src/address-list/README.zh-CN.md index ca8dcc00f..126306f2b 100644 --- a/src/address-list/README.zh-CN.md +++ b/src/address-list/README.zh-CN.md @@ -117,6 +117,7 @@ export default { | default | 在列表下方插入内容 | - | | top | 在顶部插入内容 | - | | item-bottom | 在列表项底部插入内容 | _item: Address_ | +| tag | 列表项标签内容自定义 | _item: Address_ | ### 样式变量 diff --git a/src/address-list/test/__snapshots__/index.spec.ts.snap b/src/address-list/test/__snapshots__/index.spec.ts.snap new file mode 100644 index 000000000..6f7b81140 --- /dev/null +++ b/src/address-list/test/__snapshots__/index.spec.ts.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render tag slot correctly 1`] = ` +
+
+
+
+ +
+
+`; diff --git a/src/address-list/test/index.spec.ts b/src/address-list/test/index.spec.ts index 8d60e339b..f6460d05e 100644 --- a/src/address-list/test/index.spec.ts +++ b/src/address-list/test/index.spec.ts @@ -50,3 +50,12 @@ test('should emit click-item event when item is clicked', () => { expect(wrapper.emitted('click-item')![0]).toEqual([list[0], 0]); }); + +test('should render tag slot correctly', () => { + const wrapper = mount(AddressList, { + slots: { + tag: () => 'Custom Tag', + }, + }); + expect(wrapper.html()).toMatchSnapshot(); +});