Stage模型
Posted 坚果的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Stage模型相关的知识,希望对你有一定的参考价值。
版本:Api9,Stage模型
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import Ability from '@ohos.application.Ability';
import AbilityStage from "@ohos.application.AbilityStage";
import context from '@ohos.application.context';
@Entry
@Component
struct Index
@State message: string = '选择单张图片'
@State img: string = ''
build()
Row()
Column()
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold).onClick(()=>
let context = getContext(this) as any
let startParmameter =
bundleName:"com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
parameters:
uri: "singleselect"
;
context.startAbilityForResult(startParmameter).then((result) =>
console.info(`startAbilityForResult Promise.resolve is called, result.resultCode = $JSON.stringify(result)`)
let want = result['want'];
console.info(`test select single $JSON.stringify(want)`);
if (want != null && want != undefined)
let param = want['parameters'];
console.info(`test select single $JSON.stringify(param)`);
if (param != null && param != undefined)
let uri = param['select-item-list'];
this.img=param['select-item-list'];
console.info(`图片路径是 $uri`);
, (error) =>
console.info(`startAbilityForResult Promise.Reject is called, error.code = $error.code`)
)
)
Image(this.img).width(50).height(50)
.width('100%')
.height('100%')
以上是关于Stage模型的主要内容,如果未能解决你的问题,请参考以下文章