我做一个好人,解决方案: const width = res[0].width const height = res[0].height const canvas = res[0].node const ctx = canvas.getContext('2d') const dpr = wx.getSystemInfoSync().pixelRatio canvas.width = width * dpr canvas.height = height * dpr ctx.scale(dpr, dpr) 需要把像素比率计算进去,完美解决
小程序中使用lottie动画为什么会失真?https://cdn.kaishuhezi.com/kstory/activity_flow/video/70fde28f-8433-449c-bce5-ecc9a5d328b9.mov <Canvas id='c1' type='2d' style={{width: '1112px', height: '1112px'}} /> Taro.createSelectorQuery().selectAll('#c1').node((res) => { const canvas = res[0].node; const context = canvas.getContext('2d'); lottie.setup(canvas); this.ani = lottie.loadAnimation({ loop: true, autoplay: true, animationData: data, rendererSettings: { context, }, }) }).exec()
2021-08-06