Closed vickyleu closed 1 year ago
import lottie from "lottie-miniprogram";
改成用这个就正常了
useReady(() => {
Taro.createSelectorQuery().select('#canvas').node((ref) => {
if(ref){
const canvas = ((ref as unknown as unknown[]).length > 0)? ref[0].node: ref.node;
if(canvas){
const context = canvas.getContext('2d');
lottie.setup(canvas)
lottie.loadAnimation({
animationData: require("assets/react.json"),
loop: true,
autoplay: true,
rendererSettings: {context},
});
}
}
}).exec();
})
<View className='right-content'>
{/* 右边的内容 */}
<Canvas id='canvas' className={`right-image ${isDisabled ? 'disabled' : ''}`}
type='2d' onTouchStart={handleClick} onTouchEnd={handleReleaseClick} onClick={() => {
}}
/>
</View>
小程序执行错误:
显示的view部分:
而且还有一些其他报错信息