我也是
wx.canvasToTempFilePath({})在安卓手机为什么无反应?苹果手机可以正常执行下面的代码在真机中预览,苹果手机可以正常执行,安卓手机点击按钮后无任何反应,这个是什么原因引起的,谢谢! 各位大侠帮忙看下,谢谢! //生成按钮点击事件 subCanvas: function () { var that = this this.data.ctx.draw(true, () => { //console.log('绘制完成'); //setTimeout(() => { }, 2500) //setTimeout(function () { }, 500); wx.canvasToTempFilePath({ canvasId: 'handWriting', fileType: 'png', quality: 1, //图片质量 success(res) { that.setData( { tempImagePath: res.tempFilePath //获取临时图片路径 }, ) var tempdata = that.data.tempImagePath wx.getImageInfo({ src: tempdata, success: (res) => { let canvasContext = wx.createCanvasContext('tempCanvas') //获得exif中的orientation信息 if (res.orientation == "up") { var width = res.width / 2; var height = res.height / 2; that.setData({ imageWidth: height, imageHeight: width, }) canvasContext.translate(height / 2, width / 2) //顺时针旋转90度,由纵向修改为横向 canvasContext.rotate(-90 * Math.PI / 180) canvasContext.drawImage(tempdata, - width / 2, - height / 2, width, height); } canvasContext.draw() that.drawImage() } }) } }) }); }, //将画布转化为图片(图片有纵向修改为横向) drawImage: function (path) { wx.showLoading({ //显示加载框 title: '', mask: false }) var that = this; setTimeout(() => { // 将生成的canvas图片,转为真实图片 wx.canvasToTempFilePath({ x: 0, y: 0, canvasId: 'tempCanvas', success(res) { //转化成功回调函数 //页面跳转 var pages = getCurrentPages(); var currPage = pages[pages.length - 1]; //当前页面 var prevPage = pages[pages.length - 2]; //上一个页面 var that = this //直接调用上一个页面对象的setData()方法,把数据存到上一个页面中去 prevPage.setData({ //设置上一个页面中的data signImageFile: res.tempFilePath, }) wx.hideLoading() //隐藏加载框 wx.navigateBack({ //返回上一个页面 delta: 1, }) }, fail: function (res) { } }) }, 2000) },
2020-03-11