欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > 二次封装 el-dialog 实现 全屏和最小化 功能

二次封装 el-dialog 实现 全屏和最小化 功能

2026/3/4 17:40:24 来源:https://blog.csdn.net/lianghecai52171314/article/details/140034894  浏览:    关键词:二次封装 el-dialog 实现 全屏和最小化 功能

效果

在这里插入图片描述

封装后的组件

 <template><el-dialog v-model="dialogVisible" :show-close="false" :fullscreen="fullscreen" draggable overflow><template #header="{ close }"><div><span style="font-weight: bolder">{{ title0 }}</span><el-icon style="cursor: pointer; float: right" @click="close"><Close /></el-icon><el-icon style="cursor: pointer; float: right; margin-right: 8px" @click="fullScreenFun"><FullScreen /></el-icon><el-icon style="cursor: pointer; float: right; margin-right: 8px" @click="close"><Minus /></el-icon></div></template><slot>默认内容</slot><template #footer><el-button @click="dialogVisible = false">取消</el-button><el-button type="primary" @click="submit"> 确定 </el-button></template></el-dialog>
</template><script setup lang="tsx" name="assignRoleDialog">
import { ref } from "vue";
// 标题
const title0 = ref("默认标题");
//弹窗是否显示
const dialogVisible = ref(false);
//是否全屏
const fullscreen = ref(false);//打开对话框
const openDialog = (title: string) => {title0.value = title;dialogVisible.value = true;
};
//关闭对话框
const closeDilog = () => {dialogVisible.value = false;
};const fullScreenFun = () => {fullscreen.value = !fullscreen.value;
};const emits = defineEmits(["fun"]);
const submit = () => {emits("fun");
};defineExpose({openDialog,closeDilog
});
</script>

页面中使用

<template><el-button @click="openDialogFun">haaha</el-button><FullScreenDialog ref="hdialog" @fun="dfun"><el-scrollbar max-height="800px"><h2>111111</h2><h2>111111</h2><!-- <h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2><h2>111111</h2> --></el-scrollbar></FullScreenDialog>
</template>
<script lant=ts>
import FullScreenDialog from "@/components/FullScreenDialog/index.vue";
const hdialog = ref();const openDialogFun = () => {hdialog.value!.openDialog("修改用户");
};
const dfun = () => {alert("执行业务代码……");hdialog.value.closeDilog();
};
</script>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词