element-plus/docs/examples/message-box/prompt.vue
JeremyWuuuuu e97fe719c4
chore(docs): update text button type (#7533)
- Update button's type in examples per changes for button
2022-05-06 17:33:52 +08:00

30 lines
741 B
Vue

<template>
<el-button text @click="open">Click to open Message Box</el-button>
</template>
<script lang="ts" setup>
import { ElMessage, ElMessageBox } from 'element-plus'
const open = () => {
ElMessageBox.prompt('Please input your e-mail', 'Tip', {
confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
inputPattern:
/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
inputErrorMessage: 'Invalid Email',
})
.then(({ value }) => {
ElMessage({
type: 'success',
message: `Your email is:${value}`,
})
})
.catch(() => {
ElMessage({
type: 'info',
message: 'Input canceled',
})
})
}
</script>