Constructor
new ImageLoader(options)
- Source:
[注] 继承了EventQueues类,附加的实例方法和属性请至EventQueues API文档查看
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | 其他配置选项见ImageLoader.options |
Extends
- EventQueues
Members
(static, readonly) options :object
- Source:
- Since:
- 1.0.0
Properties:
| Name | Type | Default | Description |
|---|---|---|---|
debug |
boolean |
false
|
打印器调试模式是否开启 |
name |
string |
'ImageLoader'
|
打印器名称标记 |
默认配置选项
Type:
- object
(readonly) $image :Image
- Source:
- Since:
- 1.0.0
load方法执行时绑定的image对象
Type:
- Image
(readonly) $blob :Blob
- Source:
- Since:
- 1.0.0
fetch方法执行时绑定的blob对象
Type:
- Blob
(readonly) $currentSrc :string
- Source:
- Since:
- 1.0.0
获取image实例的当前图片地址
Type:
- string
(readonly) $complete :boolean
- Source:
- Since:
- 1.0.0
获取image实例对应图片是否下载过
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- boolean
(readonly) $status :string
- Source:
- Since:
- 1.2.2
获取image实例对应图片的下载是否成功状态值
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- string
(readonly) $loaded :boolean
- Source:
- Since:
- 1.2.2
获取image实例对应图片是否已下载过
Type:
- boolean
(readonly) $width :number
- Source:
- Since:
- 1.0.0
获取image实例的设置宽度
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- number
(readonly) $naturalWidth :number
- Source:
- Since:
- 1.0.0
获取image实例对应图片的真实宽度
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- number
(readonly) $height :number
- Source:
- Since:
- 1.0.0
获取image实例的设置高度
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- number
(readonly) $naturalHeight :number
- Source:
- Since:
- 1.0.0
获取image实例对应图片的真实高度
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- number
(readonly) $ext :string
- Source:
- Since:
- 1.0.0
获取当前文件扩展名
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Type:
- string
(readonly) $mime :string
- Source:
- Since:
- 1.0.0
获取当前文件的mime类型
仅在调用ImageLoader#fetch方法时有效
Type:
- string
(readonly) $size :number
- Source:
- Since:
- 1.0.0
获取当前文件的大小,单位:字节
仅在调用ImageLoader#fetch方法后,该值有效
Type:
- number
Methods
(static) config(options) → {ImageLoader}
- Source:
- Since:
- 1.0.0
- See:
更新默认配置选项
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | 其他配置选项见ImageLoader.options |
Returns:
- Type
- ImageLoader
(async) load(imageSrcopt, widthopt, heightopt) → {Promise}
- Source:
- Since:
- 1.0.0
载入图片
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
imageSrc |
string |
<optional> |
''
|
图片地址 |
width |
number |
<optional> |
图片显示的宽 |
|
height |
number |
<optional> |
图片显示的高 |
Returns:
- Type
- Promise
(async) fetch(imageSrcopt) → {Promise}
- Source:
- Since:
- 1.0.0
以ajax方式获取图片资源,该方式获取的资源可以统计资源的容量大小
此时,可以取实例上的ImageLoader#$mime和ImageLoader#$size两个实例属性
[注] 若图片地址是dataURL格式,则直接返回dataURL,且ImageLoader#$size对应的是dataURL的容量大小(并不是原图片的容量大小)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
imageSrc |
string |
<optional> |
''
|
图片地址 |
Returns:
- Type
- Promise
(async) base64(formatopt) → {Promise}
- Source:
- Since:
- 1.0.0
输出base64格式
[注] 请确保在是在调用ImageLoader#load或ImageLoader#fetch实例方法后调用该属性
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
format |
string |
<optional> |
输出的图片格式,默认保存原图片后缀格式 |
Returns:
- Type
- Promise