mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 18:01:24 +08:00
39 lines
949 B
Vue
39 lines
949 B
Vue
|
<template>
|
||
|
<el-button type="text" @click="open">Click to open Message Box</el-button>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts">
|
||
|
import { defineComponent } from 'vue'
|
||
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
||
|
|
||
|
export default defineComponent({
|
||
|
setup() {
|
||
|
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',
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
open,
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
</script>
|