From 778b9c70fc986ee1db5449ea278da97e95383c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E5=BC=BA=E6=A0=87?= Date: Mon, 28 Mar 2022 06:50:46 +0000 Subject: [PATCH] fix getThumbnail promise Signed-off-by: panqiangbiao --- .../reference/apis/js-apis-medialibrary.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index f0ce12ad54..4fa7c3841d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -1149,15 +1149,19 @@ getThumbnail(size?: Size): Promise<image.PixelMap> async function example() { let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], - order: fileKeyObj.DATE_ADDED + " DESC", - extendArgs: "", + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.getThumbnail(size, (err, pixelmap) => { + asset.getThumbnail(size) + .then((pixelmap) => { console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }) + .catch((err) => { + console.info('mediaLibraryTest : getThumbnail fail'+ err); }); } ``` -- GitLab