修复自适应的返回异常

This commit is contained in:
aixianling
2023-10-25 10:54:41 +08:00
parent 5620d9aeb9
commit 24b7be6b32

View File

@@ -15,7 +15,8 @@ export default {
height: 1080 height: 1080
}, },
width: 0, width: 0,
height: 0 height: 0,
observer: null
} }
}, },
computed: { computed: {
@@ -37,7 +38,11 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(this.initSize) this.$nextTick(this.initSize)
window.onresize = () => this.$nextTick(this.initSize) this.observer = new ResizeObserver(this.initSize)
this.observer.observe(this.$el)
},
beforeDestroy() {
this.observer?.disconnect()
} }
} }
</script> </script>