wxml代码:
<ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ecPie }}"></ec-canvas>
js代码:
var pieId = this.selectComponent('#mychart-pie');
pieId.canvasToTempFilePath({
x: 100,
y: 200,
width: 50,
height: 50,
destWidth: 100,
destHeight: 100,
fileTpye:'png',
canvasId: 'mychart-pie',
success(res) {
console.log(res.tempFilePath);
imgUrl=res.tempFilePath;
wx.saveImageToPhotosAlbum({
filePath:res.tempFilePath
})
},
fail(error){
console.log(error);
}
},this);
没有报错,保存的图片打开后空白
var pieId = this.selectComponent('#mychart-pie');
只是ec-canvas组件的实例,不是canvas的实例