项目里面有个input调用系统相册功能,发现取消后第二次点击失效
<input class="input-file" multiple="multiple" ref="avatarInput" @change="changeImage($event)" type="file" name="image" accept="image/*">
原因是相册取消后一直在等待结果返回。
private void uploadImgFromSysPhotos(int resultCode, Intent intent) {
if (mUploadMessage != null) {//5.0以下
Uri result = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
mUploadMessage.onReceiveValue(result);
} else if (uploadMessage != null) {//5.0+
Uri[] uris = new Uri[1];
uris[0] = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
if (uris[0] != null) {
uploadMessage.onReceiveValue(uris);
} else
//取消后代码走这里,所以返回个空给input。
uploadMessage.onReceiveValue(null);
}
uploadMessage = null;
}