HarmonyOS【ArkUI组件---Image组件】

1.实现效果

2.Image:图片显示组件

3.通过网络图片

javascript 复制代码
@Entry
@Component
struct Index {
  @State message: string = 'Hello World'

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .fontColor('#36D')
          .onClick(()=>{
            this.message='Hello ArkTS!'
          })
        Image('https://res.vmallres.com/uomcdn/CN/cms/202406/2db7e1ea3fbf40fbac8adce59b04f44d.png')
          .width(250)
      }

      .width('100%')
    }
    .height('100%')
  }
}

4.网络访问权限

当我们没有配置权限的时候,只能在预览器中看见网络图片,在模拟器上不可以

打开module.json5文件

javascript 复制代码
 "requestPermissions": [
      {
        "name":"ohos.permission.INTERNET"
      }
    ],

添加之后,效果如下图所示 :

5.本地图片

javascript 复制代码
 Image($r('app.media.app_icon'))
          .width(250)
          .interpolation(ImageInterpolation.High)
相关推荐
lilian2335 小时前
Harmony os 技术实战|拼豆制图09:把 50 张图库素材做成可复跑的生产管线
华为·harmonyos
chjif6 小时前
Android 设备管控开发实战:企业受控终端的 DNS 域名策略实现
android·华为·harmonyos
OH_TPC7 小时前
【鸿蒙优选三方库】@ohos/grpc:在 HarmonyOS 上像调本地方法一样调远程服务
华为·harmonyos·鸿蒙
达子6667 小时前
第30章_综合案例:HarmonyOs开发图解之 俄罗斯方块游戏
游戏·华为·harmonyos
云端漫步19877 小时前
HarmonyOS NEXT AI 应用开发总结:30 篇之旅
人工智能·华为·harmonyos
math_hongfan8 小时前
鸿蒙Agent高级技能自定义开发:自定义意图服务/能力注册/Agent技能编排/服务插件开发实战
android·学习·华为·harmonyos·鸿蒙
math_hongfan8 小时前
鸿蒙AI权限与隐私保护高级:智能数据脱敏/端侧处理优先/数据最小化采集/隐私计算技术栈
人工智能·学习·华为·harmonyos·鸿蒙
云端漫步198710 小时前
HarmonyOS NEXT AI 智能生活助手:项目打包与发布
人工智能·华为·生活·harmonyos
less_1213811 小时前
HarmonyOS WPS Open SDK:关闭回传 URI-FD 与沙箱 filePath
华为·harmonyos·wps
math_hongfan12 小时前
鸿蒙多模态AI交互高级:图文+语音+手势融合交互/多模态大模型端侧适配/跨模态检索高阶实战
人工智能·学习·华为·交互·语音识别·harmonyos·鸿蒙