UNPKG

@huyuchen/visual

Version:

## 组件环境

66 lines (65 loc) 1.58 kB
import { openBlock as i, createElementBlock as c, normalizeStyle as a, renderSlot as l } from "vue"; import "./HuLargeScreen.vue2.js"; import h from "../_virtual/_plugin-vue_export-helper.js"; const d = { name: "HuLargeScreen", //参数注入 props: { width: { type: String, default: "1920" }, height: { type: String, default: "1080" } }, data() { return { style: { width: this.width + "px", height: this.height + "px", transform: "scale(1)" // translate(-50%, -50%) } }; }, mounted() { this.setScale(), window.onresize = this.Debounce(this.setScale, 1e3); }, methods: { Debounce: (e, t) => { const r = t || 500; let n; return function() { const s = arguments; n && clearTimeout(n); const o = this; n = setTimeout(() => { n = null, e.apply(o, s); }, r); }; }, // 获取放大缩小比例 getScale() { const e = window.innerWidth / this.width, t = window.innerHeight / this.height; return e < t ? e : t; }, // 设置比例 setScale() { this.style.transform = "scale(" + this.getScale() + ") ", console.log("任你千变万化,我都不会影响性能"); } } }; function u(e, t, r, n, s, o) { return i(), c("div", { class: "ScreenAdapter", style: a(s.style) }, [ l(e.$slots, "default", {}, void 0, !0) ], 4); } const g = /* @__PURE__ */ h(d, [["render", u], ["__scopeId", "data-v-c4d7f961"]]); export { g as default };