2021-09-17 00:18:50 +08:00
|
|
|
<template>
|
|
|
|
<el-radio-group v-model="direction">
|
|
|
|
<el-radio label="ltr">left to right</el-radio>
|
|
|
|
<el-radio label="rtl">right to left</el-radio>
|
|
|
|
<el-radio label="ttb">top to bottom</el-radio>
|
|
|
|
<el-radio label="btt">bottom to top</el-radio>
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
|
|
<el-button type="primary" style="margin-left: 16px" @click="drawer = true">
|
|
|
|
open
|
|
|
|
</el-button>
|
2022-01-17 14:58:06 +08:00
|
|
|
<el-button type="primary" style="margin-left: 16px" @click="drawer2 = true">
|
|
|
|
with footer
|
|
|
|
</el-button>
|
2021-09-17 00:18:50 +08:00
|
|
|
|
|
|
|
<el-drawer
|
|
|
|
v-model="drawer"
|
|
|
|
title="I am the title"
|
|
|
|
:direction="direction"
|
|
|
|
:before-close="handleClose"
|
|
|
|
>
|
|
|
|
<span>Hi, there!</span>
|
|
|
|
</el-drawer>
|
2022-01-17 14:58:06 +08:00
|
|
|
<el-drawer v-model="drawer2" :direction="direction">
|
|
|
|
<template #title>
|
|
|
|
<h4>set title by slot</h4>
|
|
|
|
</template>
|
|
|
|
<template #default>
|
|
|
|
<div>
|
|
|
|
<el-radio v-model="radio1" label="Option 1" size="large"
|
|
|
|
>Option 1</el-radio
|
|
|
|
>
|
|
|
|
<el-radio v-model="radio1" label="Option 2" size="large"
|
|
|
|
>Option 2</el-radio
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #footer>
|
|
|
|
<div style="flex: auto">
|
|
|
|
<el-button @click="cancelClick">cancel</el-button>
|
|
|
|
<el-button type="primary" @click="confirmClick">confirm</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-drawer>
|
2021-09-17 00:18:50 +08:00
|
|
|
</template>
|
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref } from 'vue'
|
2021-09-17 00:18:50 +08:00
|
|
|
import { ElMessageBox } from 'element-plus'
|
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
const drawer = ref(false)
|
2022-01-17 14:58:06 +08:00
|
|
|
const drawer2 = ref(false)
|
2021-12-21 15:51:33 +08:00
|
|
|
const direction = ref('rtl')
|
2022-01-17 14:58:06 +08:00
|
|
|
const radio1 = ref('Option 1')
|
2021-12-21 15:51:33 +08:00
|
|
|
const handleClose = (done: () => void) => {
|
|
|
|
ElMessageBox.confirm('Are you sure you want to close this?')
|
|
|
|
.then(() => {
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
// catch error
|
|
|
|
})
|
|
|
|
}
|
2022-01-17 14:58:06 +08:00
|
|
|
function cancelClick() {
|
|
|
|
drawer2.value = false
|
|
|
|
}
|
|
|
|
function confirmClick() {
|
|
|
|
ElMessageBox.confirm(`Are you confirm to chose ${radio1.value} ?`)
|
|
|
|
.then(() => {
|
|
|
|
drawer2.value = false
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
// catch error
|
|
|
|
})
|
|
|
|
}
|
2021-09-17 00:18:50 +08:00
|
|
|
</script>
|