欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > vue前端可视化大屏页面适配方案

vue前端可视化大屏页面适配方案

2025/7/17 1:38:59 来源:https://blog.csdn.net/xiaoxiongxia/article/details/145638643  浏览:    关键词:vue前端可视化大屏页面适配方案

参考了其他博主的代码,但发现会有滚动条,并且居中的位置不太对,所以改了一下css,修复了这些问题,直接上代码

<template>
<div class="ScaleBoxA"><divclass="ScaleBox"ref="ScaleBox":style="{width: width + 'px',height: height + 'px',}"><!--  内容  --></div>
</div>
</template>
<script>
export default {name: 'index',data() {return {scale: 0,width: 1920,height: 1080,}}, methods: {getScale() {const { width, height } = thisconst wh = window.innerHeight / heightconst ww = window.innerWidth / widthreturn ww < wh ? ww : wh},setScale() {this.scale = this.getScale()if (this.$refs.ScaleBox) {this.$refs.ScaleBox.style.setProperty('--scale', this.scale)}},debounce(fn, delay) {const delays = delay || 500let timerreturn function () {const th = thisconst args = argumentsif (timer) {clearTimeout(timer)}timer = setTimeout(function () {timer = nullfn.apply(th, args)}, delays)}},},mounted() {this.setScale()window.addEventListener('resize', this.debounce(this.setScale))},
}
<style lang="scss" scoped>
#ScaleBox {--scale: 1;
}
.ScaleBoxA {top: 0;width: 100vw;height: 100vh;position: fixed;display: flex;align-items: center;justify-content: center;
}
.ScaleBox {transform: scale(var(--scale));display: flex;flex-direction: column;transform-origin: 960px 540px;transition: 0.3s;z-index: 999;
}
</style>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词