harmony 鸿蒙Adding an Image

  • 2022-08-09
  • 浏览 (844)

Adding an Image

Generally, the <image> component is used to add images on a page. The method of using this component is similar to that of using the Text component.

To reference images via the <image> component, you are advised to store the image files under js\default\common. (You need to create the common directory on your own.) For details about the directory structure, see Directory Structure. The following sample code shows you how to add an image and set its style.

<!-- xxx.hml -->
<image class="img" src="{{middleImage}}"></image>
/* xxx.css */
.img {  
  margin-top: 30px;
  margin-bottom: 30px;
  height: 385px;
}
// xxx.js
export default {
  data: {
    middleImage: '/common/ice.png',
  },
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI

harmony 鸿蒙Atomic Service Full Screen Launch Component (FullScreenLaunchComponent)

harmony 鸿蒙Arc Button (ArcButton)

harmony 鸿蒙Animation Smoothing

harmony 鸿蒙Animation Overview

harmony 鸿蒙Frame Animation (ohos.animator)

harmony 鸿蒙Implementing Property Animation

harmony 鸿蒙Property Animation Overview

harmony 鸿蒙Dialog Box Overview

harmony 鸿蒙Blur Effect

0  赞