MiniX自绘渲染跨平台框架
  • 框架说明
  • 声明式开发范式
  • 内置Api
指南
接口
  • Minix CLI
示例
  • 类Web框架

    • 框架说明
    • 类Web开发范式
    • 内置Api
  • 指南
  • 组件
  • 接口
  • 示例
  • 规范
  • DophinHybrid

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • DolphinWeex

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • 发布消息
  • 常见问题
  • 更新日志
  • 框架说明
  • 声明式开发范式
  • 内置Api
指南
接口
  • Minix CLI
示例
  • 类Web框架

    • 框架说明
    • 类Web开发范式
    • 内置Api
  • 指南
  • 组件
  • 接口
  • 示例
  • 规范
  • DophinHybrid

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • DolphinWeex

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • 发布消息
  • 常见问题
  • 更新日志

# Image对象

说明: 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

图片对象。

# 属性

属性 类型 默认值 必填 描述
src string - 是 图片资源的路径。
width <length> 0px 否 图片的宽度。
height <length> 0px 否 图片的高度。
onload Function - 否 图片加载成功后触发该事件,无参数。
onerror Function - 否 图片加载失败后触发该事件,无参数。

# 示例

<!-- xxx.mxl -->
<div>
  <canvas ref="canvas" style="width: 500px; height: 500px; "></canvas>
</div>
1
2
3
4
// xxx.js
export default {
  onShow(){
    const el =this.$refs.canvas;
    var ctx =el.getContext('2d');  
    var img = new Image();
    img.src = 'common/images/example.jpg';
    img.onload = function() {
    console.log('Image load success');
    ctx.drawImage(img, 0, 0, 360, 250);
   };
    img.onerror = function() {
    console.log('Image load fail');
    };
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

zh-cn_image_0000001198530395