mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-16 03:53:39 +08:00

* feat(components): [Notification] add support for message as a Function * feat: add example of Notification with VNode * Update docs/en-US/component/notification.md Co-authored-by: btea <2356281422@qq.com> * feat: update version --------- Co-authored-by: btea <2356281422@qq.com>
35 lines
846 B
Vue
35 lines
846 B
Vue
<template>
|
|
<el-button plain @click="open">Common VNode</el-button>
|
|
<el-button plain @click="open1">Dynamic props</el-button>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { h, ref } from 'vue'
|
|
import { ElNotification, ElSwitch } from 'element-plus'
|
|
|
|
const open = () => {
|
|
ElNotification({
|
|
title: 'Use Vnode',
|
|
message: h('p', null, [
|
|
h('span', null, 'Message can be '),
|
|
h('i', { style: 'color: teal' }, 'VNode'),
|
|
]),
|
|
})
|
|
}
|
|
|
|
const open1 = () => {
|
|
const checked = ref<boolean | string | number>(false)
|
|
ElNotification({
|
|
title: 'Use Vnode',
|
|
// Should pass a function if VNode contains dynamic props
|
|
message: () =>
|
|
h(ElSwitch, {
|
|
modelValue: checked.value,
|
|
'onUpdate:modelValue': (val: boolean | string | number) => {
|
|
checked.value = val
|
|
},
|
|
}),
|
|
})
|
|
}
|
|
</script>
|