1. 移除多余div

2. 传递事件到父组件
This commit is contained in:
wsgh0202 2025-06-25 23:54:52 +08:00
parent a3db419575
commit 408b3efd93
No known key found for this signature in database
GPG Key ID: F9658C3FEDCF6979

View File

@ -1,6 +1,10 @@
<template>
<VPopup v-model="showPopup" class="bigger-preview-video-container" @popup-change="onPopupChange">
<div ref="popupContent"></div>
<VPopup
ref="popup"
v-model="showPopup"
class="bigger-preview-video-container"
@popup-change="onPopupChange"
>
</VPopup>
</template>
@ -36,19 +40,19 @@ export default defineComponent({
this.originalParent = dom.parentNode
this.originalNextSibling = dom.nextSibling
this.showPopup = true
// popupContent
this.togglePopup()
// popup
this.$nextTick(() => {
const popupContent = this.$refs.popupContent as HTMLElement
if (popupContent && dom.parentNode !== popupContent) {
popupContent.appendChild(dom)
const popup = this.$refs.popup as any
if (popup && dom.parentNode !== popup) {
popup.$el.appendChild(dom)
this.movedDom = dom
}
})
},
closePopup() {
this.restoreDom()
this.showPopup = false
this.togglePopup()
},
restoreDom() {
if (this.movedDom && this.originalParent) {
@ -66,6 +70,14 @@ export default defineComponent({
if (!val) {
this.restoreDom()
}
this.$emit('popup-change', val)
},
togglePopup() {
// VPopuptoggle
const popup = this.$refs.popup as any
if (popup && typeof popup.toggle === 'function') {
popup.toggle()
}
},
},
})