<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<button type="default" @click="onDrowImg">点击获取图像信息</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
onDrowImg() {
let promise1 = new Promise((resolve, reject) => {
let avatar = 'http://shopmakeup-static.zonejoin.cn/2019/3/17/102215761978855342.png'
/* 获得要在画布上绘制的图片 => 头像 */
uni.getImageInfo({
src: avatar,
success: res => resolve(res)
})
});
let promise2 = new Promise((resolve, reject) => {
/* 获得要在画布上绘制的图片 => 背景图 */
let src = 'https://shopnaly-s.zonejoin.cn/2020/3/20/14324957502702095.png'
uni.getImageInfo({
src: src,
success: res =>resolve(res)
});
});
let promise3 = new Promise((resolve, reject) => {
/* 获得要在画布上绘制的logo*/
uni.getImageInfo({
src: 'https://shopnaly-s.zonejoin.cn/2020/1/3/12.png',
success: res => resolve(res),
fail: error => reject(error)
});
});
let promise4 = new Promise((resolve, reject) => {
/* 获得要在画布上绘制的logo*/
uni.getImageInfo({
src: 'http://img.huangxiaoyong.com/8c3a41ac9c08118898944270d7d6087b.png',
success: res => resolve(res),
fail: error => reject(error)
});
});
let promise5 = new Promise((resolve, reject) => {
/* 获得要在画布上绘制的logo*/
uni.getImageInfo({
src: 'http://img.huangxiaoyong.com/2e2c03117c2924d170fe8e057f4dbbc7.png',
success: res => resolve(res),
fail: error => reject(error)
});
});
Promise.all(
[promise1, promise2, promise3, promise4,promise5]
).then(res => {
console.log(res)
}).catch(error => {
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
- 发布:2020-11-06 14:58
- 更新:2020-11-09 15:49
- 阅读:1920
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 10.15.6
HBuilderX类型: Alpha
HBuilderX版本号: 2.9.7
手机系统: Android
手机系统版本号: Android 11
手机厂商: 小米
手机机型: 小米MIX3
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
多次点击,会发现返回的path 有大概率重复
多次点击,会发现返回的path 有大概率重复
预期结果:
希望获取的path值想对应
希望获取的path值想对应
实际结果:
实际大概率重复
实际大概率重复
bug描述:
多个并发请求的uni.getImageInfo ,返回的path 大概率重复
如下图返回的结果, 1604645769068 这个重复出现了3次,在做分享海报时会用到。
经过测试。 正式版 2.9.7 跟 alpha 版 2.9.7 都存在该问题
[{
"path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769046",
"width": 150,
"height": 150,
"orientation": "up",
"type": "png",
"errMsg": "getImageInfo:ok"
}, {
"path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769067",
"width": 750,
"height": 1334,
"orientation": "up",
"type": "png",
"errMsg": "getImageInfo:ok"
}, {
"path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",
"width": 374,
"height": 117,
"orientation": "up",
"type": "png",
"errMsg": "getImageInfo:ok"
}, {
"path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",
"width": 750,
"height": 1334,
"orientation": "up",
"type": "png",
"errMsg": "getImageInfo:ok"
}, {
"path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",
"width": 374,
"height": 117,
"orientation": "up",
"type": "png",
"errMsg": "getImageInfo:ok"
}]
6***@qq.com (作者)
2.9.8版本在11月10号更新,未解决该问题,下个版本会更新吗?
2020-11-11 09:19
DCloud_Android_zl
回复 6***@qq.com: 下个版本会更新
2020-11-11 12:21