mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
feat(components): [el-notification] add context for notification (#6368)
- Add context for notify method - Add documentation for adding appContext for notification - Fix a bug which message[type] method connot get context - Enhance documentation for ElMessage
This commit is contained in:
parent
d5f6f795cd
commit
69de57b8d4
@ -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 <el-tag>> 2.0.2</el-tag>
|
||||
## App context inheritance <el-tag>> 2.0.4</el-tag>
|
||||
|
||||
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.
|
||||
|
||||
|
@ -130,16 +130,19 @@ const message: MessageFn & Partial<Message> & { _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
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user