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FJZolK5JwNotyeR65+7k9Ne6fHdW9zYw8tPbMFWZeQ+DgHjjnB/DPoazpyb3HU02NFdQZZVE6MGCk/IDg8Z6fp7EfWoJZGt7x5A4BdQ2EOA3uOo/Mdz7E83a+VeX0U89lHCbmRr1WZV+YeXsGQMnOWSTPT52xyOdvxFJHHpsk3nRQPIBCGLY2licMD6ZOcgZwD6EVoZJuSF03VTdR+ZuaNFc8r8ybSAy8duCnA6Zxwc1JqWuXNu1rHaWSyGeQxl5ZCiqQhfPCMSMKfQ9PXjKto30/VPsb3FsZLiACNbf5AoXIYMhySSCMd/lx/DTdWazW90lL27SyH2hjxcGPCiKTneGBAyQOCM7h60uhpBvmsX9Kv57qdmmiWKWEEM0M3moy/3skDnduDL1BGeMjOkt7cSIsiPFgLkgjAz6HrjpxyM5rE0W3t2hu4LGRb23gkkInjbchZyXChtxLEBhnr165JxrFZoAXScI5IVmc53fXPGR/Luaa2Jd032JkvNo2oWTH8MiqAPplh3z64ooksoCAsonVlzyicN74AIHT60UB7xbNrmUyCaRWP93aM/Xjn8arvCpXDEt5UgjXPo23P6EiiigfchihCI8QdjGJFypAIP7wrzx6KKgkBg1NwjN+7Rtm452/ITiiimZ9EX5okmsUmdBlIiwUdOgP8ASsyC4Z3WAqoSRgpwOgPb8Ov1+poooLnuM+2PuRio+QYX5mGP19OKvabiWbzXGXJY5JJPG0Dr9TRRQKO6NTauzZtG3GNuOMVVbDnyHG5PM2ZJOcbM9f0+lFFI3ZRN5NZoURg6rIyAPzgDGOn1ooopmCbsf//Z

HarmonyOS
3天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa

@Entry
@Component
struct ImageTest {
  @State message: string = 'Hello World';
  @State imageStr: string = '/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgND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licMD6ZOcgZwD6EVoZJuSF03VTdR+ZuaNFc8r8ybSAy8duCnA6Zxwc1JqWuXNu1rHaWSyGeQxl5ZCiqQhfPCMSMKfQ9PXjKto30/VPsb3FsZLiACNbf5AoXIYMhySSCMd/lx/DTdWazW90lL27SyH2hjxcGPCiKTneGBAyQOCM7h60uhpBvmsX9Kv57qdmmiWKWEEM0M3moy/3skDnduDL1BGeMjOkt7cSIsiPFgLkgjAz6HrjpxyM5rE0W3t2hu4LGRb23gkkInjbchZyXChtxLEBhnr165JxrFZoAXScI5IVmc53fXPGR/Luaa2Jd032JkvNo2oWTH8MiqAPplh3z64ooksoCAsonVlzyicN74AIHT60UB7xbNrmUyCaRWP93aM/Xjn8arvCpXDEt5UgjXPo23P6EiiigfchihCI8QdjGJFypAIP7wrzx6KKgkBg1NwjN+7Rtm452/ITiiimZ9EX5okmsUmdBlIiwUdOgP8ASsyC4Z3WAqoSRgpwOgPb8Ov1+poooLnuM+2PuRio+QYX5mGP19OKvabiWbzXGXJY5JJPG0Dr9TRRQKO6NTauzZtG3GNuOMVVbDnyHG5PM2ZJOcbM9f0+lFFI3ZRN5NZoURg6rIyAPzgDGOn1ooopmCbsf//Z';
  build() {
    Row() {
      Column() {
        // Image($r('app.media.background')).objectFit(ImageFit.Cover).width('100%').height('80%')
        Image("data:image/png;base64,"+this.imageStr+"").height('100vp')
      }
      .width('100%')
      .justifyContent(FlexAlign.Start)
    }
    .height('100%')
  }
}
分享
微博
QQ
微信
回复
3天前
相关问题
ArrayBuffer怎样字符串
523浏览 • 1回复 待解决
如何实现MapJSON字符串
1131浏览 • 1回复 待解决
HarmonyOS 十六进制字符明文字符串
173浏览 • 1回复 待解决
如何将PixelMap图片base64字符串
539浏览 • 1回复 待解决
如何将JSON字符串Class对象
467浏览 • 1回复 待解决
如何将图片base64字符串PixelMap?
613浏览 • 1回复 待解决
如何将Uint8Array字符串
598浏览 • 1回复 待解决
HarmonyOS Uint8Array格式字符串的方法
850浏览 • 1回复 待解决
如何将JSON字符串Class对象数组?
483浏览 • 1回复 待解决
检查字符串是否以给定的字符串开头
535浏览 • 1回复 待解决
HarmonyOS 图片转为base64字符串
194浏览 • 1回复 待解决
HarmonyOS 字符串显示异常
461浏览 • 1回复 待解决
HarmonyOS字符串替换问题
870浏览 • 1回复 待解决
检查字符串是否以给定的字符串结尾
422浏览 • 1回复 待解决
HarmonyOS $r 字符串替换问题
914浏览 • 1回复 待解决
HarmonyOS 替换字符串问题
36浏览 • 1回复 待解决
HarmonyOS 字符串编码问题
48浏览 • 1回复 待解决