mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 09:50:58 +08:00
e97fe719c4
- Update button's type in examples per changes for button
35 lines
848 B
Vue
35 lines
848 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'
|
|
import type { Action } from 'element-plus'
|
|
const open = () => {
|
|
ElMessageBox.confirm(
|
|
'You have unsaved changes, save and proceed?',
|
|
'Confirm',
|
|
{
|
|
distinguishCancelAndClose: true,
|
|
confirmButtonText: 'Save',
|
|
cancelButtonText: 'Discard Changes',
|
|
}
|
|
)
|
|
.then(() => {
|
|
ElMessage({
|
|
type: 'info',
|
|
message: 'Changes saved. Proceeding to a new route.',
|
|
})
|
|
})
|
|
.catch((action: Action) => {
|
|
ElMessage({
|
|
type: 'info',
|
|
message:
|
|
action === 'cancel'
|
|
? 'Changes discarded. Proceeding to a new route.'
|
|
: 'Stay in the current route',
|
|
})
|
|
})
|
|
}
|
|
</script>
|