采用element-plus的拖拽功能代码,在此基础上增加了记忆拖拽上次拖拽位置的功能,开袋即食;
前提:每次关闭弹窗都要销毁;
解决了默认设置transform的偏移量后首次拖拽弹窗偏移量错误的问题修改。
<template><el-dialogref="popupRefDialog":title="title"v-model="visibleNew":modal="modal":close-on-click-modal="false":width="width":append-to-body="false"destroy-on-close:class="`${props.class} cus-dialog`"@opened="initDrag"@close="_cancel":before-close="beforeClose"><slot></slot><template #footer v-if="footer"><div class="dialog-footer"><el-button round color="#337ECC" type="primary" :loading="loading" @click="_confirm">{{ loading ? '正在提交' : '提交' }}</el-button><el-button round class="transparent-btn" @click="_cancel">取 消</el-button></div></template></el-dialog>
</template>
<script setup>
import cache from "@/utils/cache";
const props = defineProps({class: {type: String,default: '',},popupType: {type: String,default: 'dialog',},