当前位置:网站首页>微信小程序图片根据屏幕比例缩放
微信小程序图片根据屏幕比例缩放
2022-07-28 00:28:00 【挚友阳光】
// 图片根据屏幕比例缩放
imageUtil(e) {
let self = this,
imageSize = {
},
originalWidth = e.detail.width,//图片原始宽
originalHeight = e.detail.height,//图片原始高
originalScale = originalHeight/originalWidth;//图片高宽比
let windowWidth = self.data.phoneInfo.windowWidth,
windowHeight = self.data.phoneInfo.windowHeight,
windowscale = windowHeight/windowWidth;//屏幕高宽比
if(originalScale < windowscale){
//图片高宽比小于屏幕高宽比
//图片缩放后的宽为屏幕宽
imageSize.imageWidth = windowWidth;
imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
}else{
//图片高宽比大于屏幕高宽比
//图片缩放后的高为屏幕高
imageSize.imageHeight = windowHeight;
imageSize.imageWidth = (windowHeight * originalWidth) / originalHeight;
};
return imageSize;
},
边栏推荐
- GBase 8c 注释信息函数
- 记录一次生产死锁
- 2022软件测试技能 Robotframework + SeleniumLibrary + Jenkins web关键字驱动自动化实战教程
- Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business
- HCIP第十三天笔记
- Digital economy is the core of future economic development
- 什么是方法,什么是方法论:了解自我精进提升的底层逻辑
- Unreal ue4.27 switchboard porting engine process
- Leetcode's 83rd biweekly match
- The story of amen
猜你喜欢

FreeRTOS kernel summary

Netease cloud copywriting

Linux Installation mysql8.0.29 detailed tutorial

萤石网络,难当「孤勇者」

数字经济才是未来经济发展的核心

N32l43x FLASH read \ write \ erase operation summary

Data security and privacy computing summit - provable security: Learning

抓包精灵NetCapture APP抓包教程《齐全》

Prediction of charitable donation behavior by EEG multivariate model analysis
![[interview: concurrent article 28:volatile] orderliness](/img/8d/c4c2ca08d8883e997709d208b7395b.png)
[interview: concurrent article 28:volatile] orderliness
随机推荐
Gbase 8C transaction ID and snapshot (III)
简单为美-编程思路
Gbase 8C recovery control function
GBase 8c 快照同步函数
[Taichi] draw a regular grid in Tai Chi
day7
day7
Real time data warehouse: meituan's real-time data warehouse construction practice
开源飞控(PX4、ardupilot)
软件测试面试题:请详细介绍一下各种测试类型的含义?
Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business
A happy old age
Establishment of elk log analysis system
ue4 unreal NDisplay插件 简易使用 三折幕 详细...
js 哪些情况不能用 JSON.parse 、JSON.stringify深拷贝及一个更好的深拷贝方法
Gbase 8C snapshot synchronization function
mongodb/mongoTemplate.upsert批量插入更新数据的实现
Blizzard Diablo 4 ps5 / PS4 beta added to Playstation database
What is method and methodology: understand the underlying logic of self-improvement
FreeRTOS kernel summary