初始化时配置好preSelectUris来实现;参考API:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-photoaccesshelper-V5参考demo:import { BusinessError } from '@ohos.base'; import photoAccessHelper from '@ohos.file.photoAccessHelper'; @Entry @Component struct Index { build() { Column() { Button('Sign in').width(150).margin({ top: 20 }) .onClick(()=>{ let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; PhotoSelectOptions.maxSelectNumber = 5; PhotoSelectOptions.preselectedUris = ['xxxxxx'] let photoPicker = new photoAccessHelper.PhotoViewPicker(); photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => { console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult)); }).catch((err: BusinessError) => { console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`); }); }) }.padding(20) } }
初始化时配置好preSelectUris来实现;
参考API:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-photoaccesshelper-V5
参考demo: