1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
image-0.md 9.01 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-06-02 01:00 . update OpenHarmony 2.0 Canary

Image

Image allows you to add an image.

Attribute

Attribute

Type

Default Value

Mandatory

Description

src

string

-

Yes

Image resource path

width

<length>

0px

No

Image width

height

<length>

0px

No

Image height

onload

Function

-

No

Called when an image is successfully loaded. This function has no parameter.

onerror

Function

-

No

Called when an image fails to be loaded. This function has no parameter.

Example

var ctx = this.$element('drawImage').getContext('2d');
var img = new Image();
img.src = 'common/image/huawei.jpg';
img.onload = function() {
  console.log('Image load success');
  ctx.drawImage(img, 200, 200);
};
img.onerror = function() {
  console.log('Image load fail');
};
1
https://gitee.com/yougl/docs.git
git@gitee.com:yougl/docs.git
yougl
docs
docs
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891