当前位置:网站首页>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;
},
边栏推荐
- Custom type: structure, enumeration, union
- Fluorite network, difficult to be a "lone brave"
- Software testing interview question: what do you think is the key to good test case design?
- 萤石网络,难当「孤勇者」
- Process data and change the name of data
- zkrollup学习资料汇总
- Gbase 8C server signal function
- C# 使用Abp仓储访问数据库时报错记录集
- Software test interview question: please introduce the meaning of various test types in detail?
- HCIP第十二天笔记
猜你喜欢

Forget the root password

【面试:并发篇28:volatile】有序性

Uniapp summary (applet)

机器学习如何做到疫情可视化——疫情数据分析与预测实战

Interviewer: are you sure redis is a single threaded process?

HyperMesh circular array - plug in

Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步

数商云供应链集采管理系统解决方案:集采系统管理模式,数字化管控企业物资

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

2022 software testing skills robotframework + selenium library + Jenkins web Keyword Driven Automation practical tutorial
随机推荐
Fiddler mobile packet capturing agent settings (for Huawei glory 60s)
如何评估研发人员效能?软件工程师报告帮你看见每个人的贡献
Vxe Table/Grid 单元格分组合并
Enterprise operation and maintenance practice - using aliyun container image service to pull and build images of overseas GCR and quay warehouses
Typescript中类的使用
GBase 8c 备份控制函数(四)
执行 Add-Migration 迁移时报 Build failed.
54:第五章:开发admin管理服务:7:人脸入库流程;人脸登录流程;浏览器开启视频调试模式(以便能够在本机的不安全域名的情况下,也能去开启摄像头);
zkrollup学习资料汇总
你所不知道的WMS
开源飞控(PX4、ardupilot)
ArcGIS:加载历史遥感影像
GBase 8c 事务ID和快照(三)
Interviewer: are you sure redis is a single threaded process?
The petrochemical industry is facing the tide of rising prices, and the digital dealer distribution system platform enables dealers and stores
测试/开发程序员的级别“陷阱“,级别不是衡量单维度的能力......
递归的使用:1.将平铺数组转为树 2.将树转化为平铺数组
IT这个岗位,人才缺口百万,薪资水涨船高,上不封顶
Cloud native enthusiast weekly: the evolution of Prometheus architecture
数据安全与隐私计算峰会-可证明安全:学习