mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 09:20:51 +08:00
e900aac6ea
* feat(message): add message component - [WIP] Messages component - TODOs: tests, VNode Bug re #101 * test(message): add tests for message component * fix(message): fix message z-index Co-authored-by: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
41 lines
860 B
Vue
41 lines
860 B
Vue
<template>
|
|
<div>
|
|
<el-button class="item" @click="handleOpen">Show Message</el-button>
|
|
<el-button class="item" @click="handleClose">Close Message</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import Message from '../src/message'
|
|
import type { IMessageHandle } from '../src/types'
|
|
import { ref } from 'vue'
|
|
|
|
export default {
|
|
setup() {
|
|
const messageBanner = ref<IMessageHandle>(null)
|
|
|
|
// methods
|
|
const handleOpen = () => {
|
|
if (messageBanner.value) return
|
|
|
|
messageBanner.value = Message({
|
|
message: "This won't close automatically",
|
|
duration: 0,
|
|
})
|
|
}
|
|
const handleClose = () => {
|
|
if (messageBanner.value) {
|
|
messageBanner.value.close()
|
|
messageBanner.value = null
|
|
}
|
|
}
|
|
|
|
return {
|
|
messageBanner,
|
|
handleOpen,
|
|
handleClose,
|
|
}
|
|
},
|
|
}
|
|
</script>
|