html
<template>
<el-dialog
:title="title"
:visible.sync="visible"
:width="width"
:before-close="handleClose"
>
<slot />
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="handleConfirm">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import { ElDialog } from 'element-plus';
export default {
name: 'ModalWrapper',
components: { ElDialog },
props: {
title: {
type: String,
default: '提示',
},
width: {
type: String,
default: '30%',
},
},
data() {
return {
visible: false,
};
},
methods: {
open() {
this.visible = true;
},
close() {
this.visible = false;
},
handleClose() {
this.close();
},
handleConfirm() {
this.$emit('confirm');
this.close();
},
},
};
</script>