bl.preloadAssets
以 Promise 风格 调用:不支持
小程序插件:不支持
功能描述
为视图层预加载媒体资源文件, 目前支持:font,image
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| data | Array. | 是 | ||
| 结构属性类型默认值必填说明typestring是合法值说明'font'字体'image'图片srcstring是 | ||||
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码
bl.preloadAssets({
data: [
{
type: 'image',
src: imgUrl,
},
],
success(resp) {
console.log('preloadAssets success', resp)
},
fail(err) {
console.log('preloadAssets fail', err)
},
})
- 开发过程中,可在开发者工具network面板查看预加载情况。