大屏自适应容器组件 v-scale-screen

vue中,v-scale-screen可用于大屏项目开发,实现屏幕自适应,可根据宽度自适应,高度自适应,和宽高等比例自适应,全屏自适应。

一、安装
npm install v-scale-screen@1.0.0

注意:vue2使用1.0.0版本,vue3使用2.0.0以上版本

二、使用

(1)在vue2中使用插件方式导出,用Vue.use()进行注册

main.js中:

import Vue from "vue";
import VScaleScreen from 'v-scale-screen'
Vue.use(VScaleScreen)

vue页面中:

<template>
  <v-scale-screen width="1920" height="1080">
    <div>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
    </div>
  </v-scale-screen>
</template>

使用时将 body样式设置为overflow: hidden

例如:在home.vue中:

<template>
  <v-scale-screen width="1920" height="1080" class="scale-wrap">
    <div class="bg">
      <div class="host-body">
        <!-- 头部 e-->
        <!-- 内容  s-->
        <router-view></router-view>
      </div>
    </div>
  </v-scale-screen>
</template>

(2)在vue3中以组件方式导出

<template>
  <v-scale-screen width="1920" height="1080">
    <div>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
      <v-chart>....</v-chart>
    </div>
  </v-scale-screen>
</template>

<script>
import { defineComponent } from "vue"
import VScaleScreen from 'v-scale-screen'

export default defineComponent({
  name:'Demo',
  components:{
    VScaleScreen
  }
})
</script>
三、API

在这里插入图片描述

v-scale-screen默认等比例屏幕缩放,当视图不满足比例,上下或左右会有留白(黑框)。如果想要铺满全屏,可以配置autoScale或将fullScreen设置为true。其原理是用到了css的transform属性实现缩放效果,进行等比例计算,达到等比例缩放的效果。

好的案例可参考:
https://gitee.com/kala0105/IofTV-Screen
https://gitee.com/MTrun/big-screen-vue-datav

相关推荐

  1. v-scale-screen 原理

    2024-07-11 18:32:08       30 阅读
  2. vue3 可视化适应屏幕组件

    2024-07-11 18:32:08       47 阅读
  3. VUE中可适化适应

    2024-07-11 18:32:08       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 18:32:08       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 18:32:08       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 18:32:08       57 阅读
  4. Python语言-面向对象

    2024-07-11 18:32:08       68 阅读

热门阅读

  1. python杨辉三角的两种书写方式

    2024-07-11 18:32:08       21 阅读
  2. 【Go - 常见的5类循环】

    2024-07-11 18:32:08       25 阅读
  3. 二叉搜索树的最近公共祖先

    2024-07-11 18:32:08       23 阅读
  4. 基于单目摄像头实现的AR多人脸捕捉效果展示

    2024-07-11 18:32:08       17 阅读
  5. git 基本使用

    2024-07-11 18:32:08       22 阅读
  6. 【智能制造-15】常见通讯协议

    2024-07-11 18:32:08       22 阅读
  7. 网络编程学习part1

    2024-07-11 18:32:08       22 阅读
  8. IQN、UUID和SCSI-ID

    2024-07-11 18:32:08       22 阅读
  9. git撤销push

    2024-07-11 18:32:08       23 阅读
  10. 解决Spring Boot中的国际化与本地化问题

    2024-07-11 18:32:08       19 阅读
  11. Mongodb索引使用限制

    2024-07-11 18:32:08       25 阅读
  12. 数据建设实践之大数据平台(七)

    2024-07-11 18:32:08       25 阅读