


Introduction to the use of the image preloading component wxapp-img-loader in WeChat applet
This article brings you an introduction to the use of the image preloading component wxapp-img-loader in the WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. help.
Since the WeChat applet does not provide JS objects like Image, it is more troublesome to preload images. The wxapp-img-loader custom component can implement image preloading in the WeChat applet. Function.
Use
1. Download the wxapp-img-loader project source code (https://github.com/o2team/wxa...), and transfer img- Copy the loader directory to your project
2. Add the following code to the WXML file of the page and introduce the component template
<import></import> <template></template>
3. Introduce the component script into the JS file of the page
const ImgLoader = require('../../img-loader/img-loader.js')
4. Instantiate an ImgLoader object and pass in this (current Page object). The second parameter is optional and is the callback method for the default image loading completion.
this.imgLoader = new ImgLoader(this)
5. Call ImgLoader The load method of the instance loads the image. The first parameter is the image link, and the second parameter is optional and is the callback method when the image is loaded. The first parameter of the callback method when the image loading is completed is the error message (null if the loading is successful), and the second parameter is the image information (Object type, including src, width and height).
this.imgLoader.load(imgUrlOriginal, (err, data) => { console.log('图片加载完成', err, data.src, data.width, data.height) })
wxapp-img-loader component can load a single image or multiple images.
running result:
Other
wxapp-img-loader project address: https://github.com/o2team/wxa...
The above is the detailed content of Introduction to the use of the image preloading component wxapp-img-loader in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.