描述: 对画布截图, 当图片太大分成2张截图数据, 当第2次调用canvasGetImageData时
, 如任何反应(success,fail,complete 这个3回调都没日志输入) 。
代码如下:
//图形快照
this.Snapshot=function()
{
var self=this;
var width = this.ChartBorder.GetChartWidth();
var height = this.ChartBorder.GetChartHeight();
if (width > 400)
{
width=400;
wx.canvasGetImageData(
{
canvasId: this.ChartBorder.UIElement.ID,
x: 0,
y: 0,
width: width,
height: height,
success(res) {
self.ScreenImageData =
{
Data: res.data,
Info: { X: 0, Y: 0, Width: width, Height: height }
};
console.log("[HQTradeFrame::Snapshot] canvasGetImageData finish. (large image. Page.1)");
console.log(self.ScreenImageData.Info);
}
});
var width2 = self.ChartBorder.GetChartWidth() - width;
var x = width;
wx.canvasGetImageData(
{
canvasId: self.ChartBorder.UIElement.ID,
x: x,
y: 0,
width: width,
height: height,
success(res) {
self.ScreenImageData2 =
{
Data: res.data,
Info: { X: x, Y: 0, Width: width2, Height: height }
};
console.log("[HQTradeFrame::Snapshot] canvasGetImageData finish. (large image. Page.2)");
console.log(self.ScreenImageData2.Info);
},
fail(res) {
console.log("[HQTradeFrame::Snapshot] canvasGetImageData finish. (large image. Page.2)");
},
complete(res){
console.log("[HQTradeFrame::Snapshot] canvasGetImageData finish. (large image. Page.2)");
}
});
}
else
{
self.ScreenImageData2 = null;
wx.canvasGetImageData(
{
canvasId: this.ChartBorder.UIElement.ID,
x: 0,
y: 0,
width: width,
height: height,
success(res) {
self.ScreenImageData =
{
Data: res.data,
Info: { X: 0, Y: 0, Width: width, Height: height }
};
console.log("[HQTradeFrame::Snapshot] canvasGetImageData finish. (small image)");
console.log(self.ScreenImageData.Info);
}
});
}
}
请问问题解决了没有 楼主
遇到同样的问题
你可以加个定时器,上一个运行完毕100ms后再运行下一个
加个定时器感觉好沙比啊。。。不能重复调用,写一个for循环发现只能调用一次
额,定时器不就是类似for循环么,只是每次都固定时间后运行,再加上回调判定,相当于把异步函数同步化