HomeDocs
Skip to main content

dlt.preloadAssets

Introduction

Preload media resource files for the view layer. Currently supports: font, image.

Usage Restrictions

Supported in the basic library from version 4.0.0 onwards.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
dataObject[]YesResources to be preloaded
successfunctionNoCallback function for a successful interface call
failfunctionNoCallback function for a failed interface call
completefunctionNoCallback function for the completion of the interface call (executed on both success and failure)

Explanation of data content types

PropertyTypeDefaultRequiredDescription
typestringYesResource type, 'font': font; 'image': image
srcstringYesResource URL

object.success Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - Set successfully

object.fail Callback Function

Parameters

Object res

PropertyTypeDescription
successstringfalse - Set failed

Sample Code

// pages/index/index.js
Page({
preloadAssets() {
dlt.preloadAssets({
data: [
{
type: 'image',
src: imgUrl,
},
],
success(res) {
console.log('preloadAssets success', res);
},
fail(err) {
console.log('preloadAssets fail', err);
},
});
},
});

Please note that this translation is based on the information provided in the text, and the function name "dlt.preloadAssets" and other specific terms may need to be adjusted according to the actual context and coding standards of your IT project. Additionally, make sure to define the imgUrl variable with the appropriate image URL before using the sample code.

Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.