diff --git a/docs/en-US/component/notification.md b/docs/en-US/component/notification.md index e4fb18a0de..9fba7fc77c 100644 --- a/docs/en-US/component/notification.md +++ b/docs/en-US/component/notification.md @@ -83,7 +83,7 @@ import { ElNotification } from 'element-plus' In this case you should call `ElNotification(options)`. We have also registered methods for different types, e.g. `ElNotification.success(options)`. You can call `ElNotification.closeAll()` to manually close all the instances. -## App context inheritance > 2.0.2 +## App context inheritance > 2.0.4 Now notification accepts a `context` as second parameter of the message constructor which allows you to inject current app's context to notification which allows you to inherit all the properties of the app. diff --git a/packages/components/message/src/message-method.ts b/packages/components/message/src/message-method.ts index a5b1523e45..703f331559 100644 --- a/packages/components/message/src/message-method.ts +++ b/packages/components/message/src/message-method.ts @@ -130,16 +130,19 @@ const message: MessageFn & Partial & { _context: AppContext | null } = } messageTypes.forEach((type) => { - message[type] = (options = {}) => { + message[type] = (options = {}, appContext?: AppContext | null) => { if (isString(options) || isVNode(options)) { options = { message: options, } } - return message({ - ...options, - type, - }) + return message( + { + ...options, + type, + }, + appContext + ) } })