python学习
This commit is contained in:
22
native/utils/image.js
Normal file
22
native/utils/image.js
Normal file
@@ -0,0 +1,22 @@
|
||||
function imageUtil (originalWidth, originalHeight) {
|
||||
let imageSize = {}
|
||||
wx.getSystemInfo({
|
||||
success: function (res) {
|
||||
const windowWidth = res.windowWidth
|
||||
imageSize.x = 0
|
||||
imageSize.y = 0
|
||||
imageSize.windowWidth = windowWidth
|
||||
imageSize.imageWidth = originalWidth
|
||||
imageSize.imageHeight = originalHeight
|
||||
if (originalWidth > windowWidth) {
|
||||
imageSize.imageWidth = windowWidth
|
||||
imageSize.imageHeight = windowWidth * originalHeight / originalWidth
|
||||
} else {
|
||||
imageSize.x = (windowWidth - originalWidth) / 2
|
||||
}
|
||||
}
|
||||
})
|
||||
return imageSize
|
||||
}
|
||||
|
||||
export default imageUtil
|
||||
Reference in New Issue
Block a user