Files
DDDDD12138 b724f7f87a feat(components): [notification] add support for message as a Function (#18558)
* 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>
2024-11-19 15:15:28 +08:00

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>