Skip to content

useScalePage

页面缩放

基础用法

<template>
  <div class="bg-gray-100">
    <div class="bg-green-100" ref="mainRef">
      我是内容
    </div>
  </div>
</template>

<script setup lang="tsx">
import { onMounted, ref, useTemplateRef } from "vue";
import { useScalePage } from "gao-components-plus";


const mainRef = useTemplateRef<HTMLElement>('mainRef')
const { init } = useScalePage({width: 500, height: 300, type: 'widthFit'})

onMounted(() => {
  init(mainRef.value!)
})

</script>

参数

名称描述类型默认值
width容器宽度Function-
height容器高度number-
type缩放类型contain | 'widthFix'widthFix

返回参数

名称描述类型默认值
init开始执行(el: htmlElement) => void-
scale缩放比例Number-
resize手动resizeFunction-

Released under the MIT License.