May 21, 2021 WeChat Mini Program Development Document
The lottie animation library adapts the version of the widget.
Please refer to the official instructions for introductions to lottie and how to generate animations
An environment that depends on the base library version of the small program, which is 2.8.0
You can refer to the snippet: https://developers.weixin.qq.com/s/2TYvm9mJ75bF. The general steps are as follows:
npm install --save lottie-miniprogram
<canvas id="canvas" type="2d"></canvas>
import lottie from 'lottie-miniprogram'
Page({
onReady() {
wx.createSelectorQuery().select('#canvas').node(res => {
const canvas = res.node
lottie.setup(canvas)
}).exec()
}
})
lottie.setup(canvas)
lottie.loadAnimation({
...
})
Two interfaces are currently available:
lottie.setup(canvas)
The canvas object needs to be called before any lottie interface calls
lottie.loadAnimation(options)
Unlike the original loadAnimation, the parameters supported are: