当前位置:   article > 正文

Stage模型_import ability from '@ohos.application.ability

import ability from '@ohos.application.ability

版本:Api9,Stage模型

  1. import mediaLibrary from '@ohos.multimedia.mediaLibrary';
  2. import Ability from '@ohos.application.Ability';
  3. import AbilityStage from "@ohos.application.AbilityStage";
  4. import context from '@ohos.application.context';
  5. @Entry
  6. @Component
  7. struct Index {
  8. @State message: string = '选择单张图片'
  9. @State img: string = ''
  10. build() {
  11. Row() {
  12. Column() {
  13. Text(this.message)
  14. .fontSize(50)
  15. .fontWeight(FontWeight.Bold).onClick(()=>{
  16. let context = getContext(this) as any
  17. let startParmameter = {
  18. bundleName:"com.ohos.photos",
  19. abilityName: "com.ohos.photos.MainAbility",
  20. parameters: {
  21. uri: "singleselect"
  22. }
  23. };
  24. context.startAbilityForResult(startParmameter).then((result) => {
  25. console.info(`startAbilityForResult Promise.resolve is called, result.resultCode = ${JSON.stringify(result)}`)
  26. let want = result['want'];
  27. console.info(`test select single ${JSON.stringify(want)}`);
  28. if (want != null && want != undefined) {
  29. let param = want['parameters'];
  30. console.info(`test select single ${JSON.stringify(param)}`);
  31. if (param != null && param != undefined) {
  32. let uri = param['select-item-list'];
  33. this.img=param['select-item-list'];
  34. console.info(`图片路径是 ${uri}`);
  35. }
  36. }
  37. }, (error) => {
  38. console.info(`startAbilityForResult Promise.Reject is called, error.code = ${error.code}`)
  39. })
  40. })
  41. Image(this.img).width(50).height(50)
  42. .width('100%')
  43. }
  44. .height('100%')
  45. }
  46. }}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/336391?site
推荐阅读
相关标签
  

闽ICP备14008679号