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
| Property | Type | Default | Required | Description | 
|---|---|---|---|---|
| data | Object[] | Yes | Resources to be preloaded | |
| success | function | No | Callback function for a successful interface call | |
| fail | function | No | Callback function for a failed interface call | |
| complete | function | No | Callback function for the completion of the interface call (executed on both success and failure) | 
Explanation of data content types
| Property | Type | Default | Required | Description | 
|---|---|---|---|---|
| type | string | Yes | Resource type, 'font': font; 'image': image | |
| src | string | Yes | Resource URL | 
object.success Callback Function
Parameters
Object res
| Property | Type | Description | 
|---|---|---|
| success | string | true - Set successfully | 
object.fail Callback Function
Parameters
Object res
| Property | Type | Description | 
|---|---|---|
| success | string | false - 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.