刚发现了一个问题,如果用wx.miniProgram.reLaunch跳转的话,第一次能出发postMessage,第二次再进同一个页面再通wx.miniProgram.reLaunch跳转的话,就不会触发postMessage了。 如果用redirectTo跳转的话就不会出现这个问题。
web-view使用postMessage参数没有传递过去,是不是使用redirect组件不算销毁?h5代码如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Authoriztion Success</title> </head> <body> <div>Loading...</div> <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> <script type="text/javascript"> wx.miniProgram.postMessage({ url:'123' }) wx.miniProgram.redirectTo({ url:'/pages/navigator/index/index' }) </script> </body> </html> 拿到数据如下 ,是空的 currentTarget: {dataset: {…}, id: "", offsetTop: 0, offsetLeft: 0} detail: data: Array(1) 0: __proto__: Object length: 1 nv_length: (...) __proto__: Array(0) __proto__: Object target: {dataset: {…}, id: "", offsetTop: 0, offsetLeft: 0} timeStamp: 18935 type: "message"
2020-03-04你好,怎么获取canvas组件实例?
如何解决Canvas 2D使用canvasToTempFilePath?onLoad() { wx.createSelectorQuery() .select('#cardCanvas') .fields({ node: true, size: true, }) .exec(this.initCanvas.bind(this)) }, initCanvas(res) { const width = res[0].width; const height = res[0].height; const canvas = res[0].node; const ctx = canvas.getContext('2d'); const dpr = wx.getSystemInfoSync().pixelRatio; canvas.width = width * dpr; canvas.height = height * dpr; ctx.scale(dpr, dpr); ctx.draw(false, () => { wx.canvasToTempFilePath({ x: 0, y: 0, width, height, destWidth: width, destHeight: height, canvasId: 'cardCanvas', fileType: 'jpg', quality: 1, success(res) { console.log(res.tempFilePath) } }) } ) } 场景是在使用canvas2d时导出画布输出到图片,但是发现如下问题 1、使用canvas2d的上下文ctx调用draw()方法的时候报错:ctx.draw is not a function;at SelectorQuery callback function 2、canvasToTempFilePath的官方文档写着在 [代码]draw()[代码]回调里调用该方法才能保证图片导出成功。文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
2020-02-28我的也这样,工具上勾上“压缩上传代码”后在真机上浏览的时候同一个页面进两次后才能正确的渲染,还有上传图片也不行,绘制canvas图片也不行。
开发者工具与真机显示不一致,开发者工具中显示正常,手机中显示不一致开发者工具与真机显示不一致,开发者工具中显示正常,手机中显示不一致 使用白鹭引擎开发,但在开发者工具中显示正常,应该不是引擎的锅 代码中使用webgl中uniform数组属性(个人认为是出错的原因) 测试机为红米6 https://pan.baidu.com/s/1gLH9wg5quTvK8Fsp9IbxbA 这是打成压缩包的
2018-12-26