如何利用vuejs指令实现不同分辨率适配?下面web建站小编给大家详细介绍一下实现代码!
兼容不同分辨率适配代码
// 缩放指令
import Vue from "vue";
function transformScale(el, options) {
const { target = "width", origin = "top left" } = options;
Vue.nextTick(() => {
// 获取显示区域高宽
const width = window.innerWidth;
const height = window.innerHeight;
el.style.transformOrigin = origin;
if (target === "ratio") {
const scaleX = width / CONF.width;
const scaleY = height / CONF.height;
el.style.transform = `scaleX(${scaleX}) scaleY(${scaleY})`;
} else {
let scaleProportion = 1;
if (target === "width") {
scaleProportion = width / CONF.width;
}
if (target === "height") {
scaleProportion = height / CONF.height;
}
el.style.transform = `scale(${scaleProportion})`;
}
});
}
function inserted(el, binding) {
const options = binding.options || { passive: true };
const callback = () => transformScale(el, binding.value);
window.addEventListener("resize", callback);
callback();
el._onResize = {
callback,
options
};
}
function unbind(el) {
if (!el._onResize) {
return;
}
const { callback } = el._onResize;
window.removeEventListener("resize", callback);
delete el._onResize;
}
export const Scale = {
inserted,
unbind
};
export default Scale;
上面是“如何利用vuejs指令实现不同分辨率适配”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2680.html
workflows工作流
一个漂亮的混血女孩ComfyUI工作流
一个港口配备了小型船只、起重机、集装箱和码头
一只巨大的古代乌龟后面建有一座城市的超现实场景
彩色雄鹰玉雕ComfyUI工作流
一只蚊子被嵌在琥珀中ComfyUI工作流
一只白色小猫comfyui工作流
图生图工作流:一键转换成高清动漫照片
一张精心制作的熊岛复古地图ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

为什么长尾关键词库的建立对SEO很重要?
六种关键词优化方法
AgentCPM-Report:清华大学等联合研发的本地化深度调研智能体
















