当前位置:网站首页>Wechat applet pictures are scaled according to the screen scale
Wechat applet pictures are scaled according to the screen scale
2022-07-28 02:05:00 【Best friend sunshine】
// The picture is scaled according to the screen scale
imageUtil(e) {
let self = this,
imageSize = {
},
originalWidth = e.detail.width,// The original width of the picture
originalHeight = e.detail.height,// The original height of the picture
originalScale = originalHeight/originalWidth;// Picture aspect ratio
let windowWidth = self.data.phoneInfo.windowWidth,
windowHeight = self.data.phoneInfo.windowHeight,
windowscale = windowHeight/windowWidth;// Screen aspect ratio
if(originalScale < windowscale){
// The picture aspect ratio is smaller than the screen aspect ratio
// The zoom width of the picture is the screen width
imageSize.imageWidth = windowWidth;
imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
}else{
// The picture aspect ratio is greater than the screen aspect ratio
// The zoom height of the picture is the screen height
imageSize.imageHeight = windowHeight;
imageSize.imageWidth = (windowHeight * originalWidth) / originalHeight;
};
return imageSize;
},
边栏推荐
猜你喜欢

53:第五章:开发admin管理服务:6:开发【admin管理员退出登录,接口】;(一个点:我们想要修改一个采用了某种编码方式的值时,新的值最好也按照这种编码方式编码后,再去修改;)

处理数据 给数据换名字

N32l43x FLASH read \ write \ erase operation summary

IT这个岗位,人才缺口百万,薪资水涨船高,上不封顶

Solution of digital commerce cloud supply chain centralized purchase management system: centralized purchase system management mode, digital control of enterprise materials

Unity universal red dot system

执行 Add-Migration 迁移时报 Build failed.

Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business

LeetCode高频题128. 最长连续序列,经常被互联网大厂面试考到

JS what situations can't use json Parse, json.stringify deep copy and a better deep copy method
随机推荐
Enterprise operation and maintenance practice - using aliyun container image service to pull and build images of overseas GCR and quay warehouses
GBase 8c 配置设置函数
Gbase 8C server signal function
Gbase 8C backup control function (IV)
如何评估研发人员效能?软件工程师报告帮你看见每个人的贡献
Gbase 8C annotation information function
学习了循环碰到了编写计算n的阶乘的题目,由此引发了一系列问题,包括一些初学者常见的坑,以及如何简化代码
Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business
UE4 unreal ndisplay plug-in easy to use three fold screen details
Gbase 8C backup control function (II)
A happy old age
Data security and privacy computing summit - provable security: Learning
HyperMesh circular array - plug in
Game 302 of leetcode
ArcGIS:加载历史遥感影像
轻量版项目管理系统
[interview: concurrent article 28:volatile] orderliness
Cloud native enthusiast weekly: the evolution of Prometheus architecture
GBase 8c 快照同步函数
Gbase 8C transaction ID and snapshot (IV)