mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1. 移除多余div
2. 传递事件到父组件
This commit is contained in:
parent
a3db419575
commit
408b3efd93
@ -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() {
|
||||
// 调用VPopup的toggle方法
|
||||
const popup = this.$refs.popup as any
|
||||
if (popup && typeof popup.toggle === 'function') {
|
||||
popup.toggle()
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user