看看效果

实现步骤:
1.选择图片
chooseImage(e) {
uni.chooseImage({
count: 1,
success: (res) => {
let index = res.tempFilePaths[0].lastIndexOf(".");
let imgUrl = res.tempFilePaths[0].substr(index + 1);
if (imgUrl != "png" && imgUrl != "jpg" && imgUrl != "jpeg") {
uni.showToast({
title: '请上传jpg、jpeg、png类型的图片',
icon: 'none'
});
return
}
if (res.tempFiles[0].size / 1024 < 1024 * 1024 * 20) {
this.originImg = res.tempFilePaths[0]
this.imageSrc = res.tempFilePaths[0]
this.loadImage();
} else {
uni.showToast({
title: '图片大小不能超过20M,当前大小' + (res.tempFiles[0].size / 1024).toFixed(
2) + 'KB',
icon: 'none'
})
}
},
});
},
图片展示区域计算
loadImage() {
uni.showLoading({
title: "图片加载中...",
});
uni.getImageInfo({
src: this.imageSrc,
success:(res) => {
let imgH = res.height;
let imgW