mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 20:27:44 +08:00
6eded0bae8
* feat(components): [message-box] allow pass function to `message` option * chore: update docs * chore: update docs
35 lines
836 B
Vue
35 lines
836 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 { ElMessageBox, ElSwitch } from 'element-plus'
|
|
|
|
const open = () => {
|
|
ElMessageBox({
|
|
title: 'Message',
|
|
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)
|
|
ElMessageBox({
|
|
title: 'Message',
|
|
// 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>
|