wx.canvasToTempFilePath,偶尔成功保存图片,大多时候没有反应,会是什么原因?
发布于 5 年前 作者 fangjun 5485 次浏览 来自 官方Issues

微信小程序使用echarts图表,点击按钮保存图表时,代码如下

const ecComponent = this.selectComponent('#mychart');

 console.log("ecComponent==============",ecComponent)

真机测试时,有时候可以保存成功,但再点击保存图片,可以打印到这里,然后就没有然后了,也不报错,会有哪些因素造成这种情况?

 ecComponent.canvasToTempFilePath({

      success: res => {},

      fail: res => console.log("fail======",res)

 });

3 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

补充:开发者工具中点击可以保存,是真机测试不稳定

加一个setTimeout试试

回到顶部