# Image
- [Attribute](#en-us_topic_0000001058948927_section1968021961113)
- [Example](#en-us_topic_0000001058948927_section13457717134912)
**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');
};
```