微信小程序 > 微信公开课 > failcanvasisempty
微信小程序,微信公开课,failcanvasisempty

failcanvasisempty

2019-03-15 18:16:34

微信公开课小程序热门讨论关于「failcanvasisempty」的小程序开发问题
补充:当前Bug的表现(可附上截图)选择图片后显示canvasToTempFilePath:failcanvasisempty预期表现返回success信息复现路径提供一个最简复现DemowxchooseImage({201932压缩上传count:1,sizeTyp
展开:当前Bug的表现选择图片后显示canvasToTempFilePath:failcanvasisempty预期表现返回success信息复现路径提供一个最简复现DemowxchooseImage({201932压缩上传count:1,sizeType:[original,compressed],success:function(res){var_that=this;varpath=restempFilePaths[0];thatdatascardimg=restempFilePaths;consolelog(theoldpath:)consolelog(restempFilePaths[0])返回选定照片的本地文件路径列表,获取照片信息wxgetImageInfo({src:restempFilePaths[0],success:function(res){利用canvas压缩图片consolelog(getinfo)consolelog(res)varratio=2;varcanvasWidth=reswidth图片原始长宽varcanvasHeight=resheightwhile(canvasWidth400||canvasHeight400){保证宽高在400以内canvasWidth=Mathtrunc(reswidthratio)canvasHeight=Mathtrunc(resheightratio)ratio++;}thatsetData({cWidth:canvasWidth,cHeight:canvasHeight})consolelog(canvasHeight)consolelog(canvasWidth)consolelog(respath)绘制图形并取出图片路径varctx=wxcreateCanvasContext(firstCanvas);ctxdrawImage(respath,0,0,canvasWidth,canvasHeight);ctxdraw();将生成好的图片保存到本地,需要延迟一会,绘制期间耗时wxshowToast({title:图片压缩中,icon:loading,duration:500});ctxdraw(false,setTimeout(function(){wxcanvasToTempFilePath({canvasId:firstCanvas,destWidth:canvasWidth,destHeight:canvasHeight,success:function(res){vartempFilePath=restempFilePath;consolelog(successcanvas);thatsetData({scardimg:restempFilePaths,img_arr:thatdatascardimgconcat(restempFilePaths),show_addimg:0});wxhideToast()},fail:function(res){consolelog(res);}})},500));}})info}success})}
更多有关「failcanvasisempty」的讨论可以前往微信公开课小程序参与互动哦!
标签:微信公开课,小程序
微信小程序,微信公开课,failcanvasisempty

「failcanvasisempty」热门讨论订阅

方法1:微信扫描微信公开课小程序码即可订阅热门讨论「failcanvasisempty」

方法2:微信搜索微信公开课小程序名称进入,即可订阅热门讨论「failcanvasisempty」

方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热门讨论「failcanvasisempty」

微信公开课小程序热门讨论「failcanvasisempty」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。

微信公开课热门讨论「failcanvasisempty」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。