当前位置: 首页 > news >正文

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>

http://www.lryc.cn/news/537158.html

相关文章:

  • Docker中安装MySql方法
  • 云轴科技ZStack+神州鲲泰,全面支持企业私有化部署DeepSeek模型
  • $ npx electron-forge import 一直报权限问题 resource busy or locked,
  • LLM:GPT 系列
  • 2025年:边缘计算崛起下运维应对新架构挑战
  • 【深度学习模型分类】
  • 【Java报错已解决】org.springframework.beans.factory.BeanCreationException
  • 理解 WebGPU 中的 GPUQueue:GPU 的命令队列
  • 电脑显示器无信号是什么原因?查看解决方法
  • Debian系发行版通用软件彻底卸载指南
  • 微信小程序地图标记点,安卓手机一次性渲染不出来的问题
  • LabVIEW软件需求开发文档参考
  • MYSQL批量UPDATE的两种方式
  • 【Viper】配置格式与支持的数据源与go案例
  • C++17 中的 std::reduce:详细教程
  • 解决 paddle ocr 遇到 CXXABI_1.3.13 not found 的问题
  • 探索 Text-to-SQL 技术:从自然语言到数据库查询的桥梁
  • mac搭建环境
  • 算法学习笔记之贪心算法
  • Docker 镜像标签使用
  • STM32之SG90舵机控制
  • VSCode Error Lens插件介绍(代码静态检查与提示工具)(vscode插件)
  • list_for_each_entry_safe 简介
  • 微软AutoGen高级功能——Memory
  • 【鸿蒙开发】第三十六章 状态管理 - V1V2混用和迁移指导
  • 轮子项目--消息队列的实现(3)
  • 一文深入了解DeepSeek-R1:模型架构
  • 秘密信息嵌入到RGB通道的方式:分段嵌or完整嵌入各通道
  • Ai人工智能的未来:趋势、挑战与机遇
  • 理解WebGPU 中的 GPUDevice :与 GPU 交互的核心接口