解决布局跳动问题

This commit is contained in:
zhcnyuyang 2025-08-21 16:25:21 +08:00
parent f5758abf93
commit 1ce63eaf10
2 changed files with 73 additions and 2 deletions

View File

@ -142,7 +142,51 @@ const { breakpoint } = useBootstrapBreakpoint();
<script> <script>
export default { export default {
name: "Aboutus" name: "Aboutus",
mounted() {
this.$nextTick(function() {
this.handleMediaLoad();
});
},
methods: {
handleMediaLoad: function() {
const container = document.getElementById('aboutusbanner');
if (container) {
//
const video = document.getElementById('abtbannervideo');
if (video) {
const handleVideoReady = () => {
container.classList.add('video-loaded');
video.removeEventListener('loadedmetadata', handleVideoReady);
video.removeEventListener('canplay', handleVideoReady);
};
video.addEventListener('loadedmetadata', handleVideoReady);
video.addEventListener('canplay', handleVideoReady);
if (video.videoWidth > 0) {
handleVideoReady();
}
}
// GIF
const img = document.querySelector('#aboutusbanner .videoimg');
if (img) {
const handleImageReady = () => {
container.classList.add('video-loaded');
img.removeEventListener('load', handleImageReady);
};
img.addEventListener('load', handleImageReady);
if (img.complete && img.naturalWidth > 0) {
handleImageReady();
}
}
}
}
}
} }
</script> </script>

View File

@ -96,7 +96,34 @@ const { breakpoint } = useBootstrapBreakpoint();
<script> <script>
export default { export default {
name: "ServiceProcess" name: "ServiceProcess",
mounted() {
this.$nextTick(function() {
this.handleImageLoad();
});
},
methods: {
handleImageLoad: function() {
const img = document.querySelector('#serviceprocessbanner .videoimg');
const container = document.getElementById('serviceprocessbanner');
if (img && container) {
//
const handleImageReady = () => {
container.classList.add('video-loaded');
//
img.removeEventListener('load', handleImageReady);
};
img.addEventListener('load', handleImageReady);
//
if (img.complete && img.naturalWidth > 0) {
handleImageReady();
}
}
}
}
} }
</script> </script>