From ba15302200392bcb8e88438148d9fa61738b912a Mon Sep 17 00:00:00 2001 From: zz <2418184580@qq.com> Date: Sun, 28 Aug 2022 13:47:30 +0800 Subject: [PATCH] fix(components): [notification] custom icon not work (#9498) --- .../components/notification/__tests__/notification.test.ts | 2 +- packages/components/notification/src/notification.ts | 5 ++--- packages/components/notification/src/notification.vue | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/components/notification/__tests__/notification.test.ts b/packages/components/notification/__tests__/notification.test.ts index ddff2cf779..17fc54ae1f 100644 --- a/packages/components/notification/__tests__/notification.test.ts +++ b/packages/components/notification/__tests__/notification.test.ts @@ -39,7 +39,7 @@ describe('Notification.vue', () => { expect(wrapper.text()).toEqual(AXIOM) expect(vm.visible).toBe(true) - expect(vm.iconComponent).toBe('') + expect(vm.iconComponent).toBeUndefined() expect(vm.horizontalClass).toBe('right') expect(vm.positionStyle).toEqual({ top: '0px', diff --git a/packages/components/notification/src/notification.ts b/packages/components/notification/src/notification.ts index b2d8e57b99..bb9ebcae2a 100644 --- a/packages/components/notification/src/notification.ts +++ b/packages/components/notification/src/notification.ts @@ -1,4 +1,4 @@ -import { buildProps, definePropType } from '@element-plus/utils' +import { buildProps, definePropType, iconPropType } from '@element-plus/utils' import type { ExtractPropTypes, VNode } from 'vue' import type Notification from './notification.vue' @@ -24,8 +24,7 @@ export const notificationProps = buildProps({ default: 4500, }, icon: { - type: definePropType([String, Object]), - default: '', + type: iconPropType, }, id: { type: String, diff --git a/packages/components/notification/src/notification.vue b/packages/components/notification/src/notification.vue index 057f35b147..154320039d 100644 --- a/packages/components/notification/src/notification.vue +++ b/packages/components/notification/src/notification.vue @@ -67,7 +67,7 @@ const typeClass = computed(() => { }) const iconComponent = computed(() => { - if (!props.type) return '' + if (!props.type) return props.icon return TypeComponentsMap[props.type] || props.icon })