- [渲染层错误] TypeError: SystemError ?
[渲染层错误] TypeError: SystemError (webviewScriptError) Cannot read property 'D' of undefined(env: Windows,mp,1.06.2405020; lib: 3.5.8) [图片] 不知道为啥出这个错误,也没有行定位,无从下手。
星期四 04:41 - worklet 函数调不起来 wx.chooseMedia ?
<long-press-gesture-handler worklet:ongesture="onTapGesture"> <canvas id="myCanvas" type="2d" style="margin: auto; width: 100%; height: 60vh;" /> </long-press-gesture-handler> onTapGesture(e) { "worklet"; console.log(e, 'start -> onTapGesture.............') chooseImage(1) console.log(e, 'end -> onTapGesture.............') }, export const chooseImage = (count = 1) => { return new Promise((resolve, reject) => { wx.chooseMedia({ count: count, mediaType: ['image'], sourceType: ['album', 'camera'], maxDuration: 30, camera: 'back' }).then(result => { const path = result.tempFiles[0].tempFilePath resolve(path) }).catch(err => { reject('USER CANCEL IN CHOOSE IMAGE') }) }) } 完整代码,我已经贴出来了
01-14 - 为什么里面的手势没有响应,外面在一直响应
https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/gesture.html <pan-gesture-handler worklet:ongesture="onGesture"> <tap-gesture-handler tag="myCanvas" worklet:ongesture="onTapGesture"> <canvas id="myCanvas" type="2d" style="margin: auto; width: 100%; height: 60vh;"/> </tap-gesture-handler> </pan-gesture-handler> 本想让点击时响应onTapGesture, 滑动时响应onGesture, 实际测试下来是,无论点击还是滑动,响应的都是外面的onGesture,搞不明白。 测试一圈发现问题 <tap-gesture-handler worklet:ongesture="onTapGesture"> <view>点击我</view> </tap-gesture-handler> 这种是工作的,也就是说tap-gesture-handler 子节点是canvas 就出问题,但如果是pan-gesture-handler 就没有问题,真是搞不懂,请官方给解答 我觉得这是一个bug. 小程序的坑真是够多了,一个一个的踩中。
01-14 - 日志行是错误的
[图片] [图片]
2024-12-26 - shared 的变量在ready()函数里进行赋值,会导致 undefined
https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.shared.html 一个组件 const position = wx.worklet.shared({ x1: 0, y1: 0 }); ready: function () { position.value = { x1: 100, y1: 100 }; //这一句会导致 下面的onGesture x1, y1 undefined undefined } onGesture(e) { "worklet"; const dx = e.deltaX; const dy = e.deltaY; const x1 = position.value.x1; const y1 = position.value.y1; position.value = { x1: x1 + dx, y1: y1 + dy }; console.log(x1, y1, 'in Ongesture') 这里读出来的是 undefined undefined ,如果去掉ready函数赋值就正常了。 } 很奇怪的现象,shared 的变量不能在ready()函数里进行赋值,这是这什么啊?
2024-12-16 - on-gesture-event worklet:ongesture
https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/gesture.htmlhttps://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html 这块儿在文档中没懂, <pan-gesture-handler worklet:ongesture="onGesture" ... <pan-gesture-handler on-gesture-event ="onGesture" .... worklet:ongesture 和 on-gesture-event 是同一个事件吗?还是不同?有点晕这个文档。
2024-12-12 - canvas 移动重绘会发生闪烁,怎么办?
onTouchMove(e) { const touch = e.touches[0]; const x = touch.x - (150 / 2) const y = touch.y - (180 / 2) this.drawImage2(x, y) }, async drawImage2(x, y) { const ctx = this.data.ctx; const bg2 = this.data.bg2 const frame = this.data.frame const width = this.data.width const height = this.data.height //画背景 drawFrame(ctx, this.data.points[0].x, this.data.points[0].y, width, height, bg2, frame) //画图片 await drawImage(this.data.canvas, ctx, x, y, width, height, '../../../images/1.png') }, 代码逻辑,在图片多动时,会重绘背景和图片本身, 但是会发生很严重的闪烁现象,这情况怎么处理?
2024-12-11 - windowHeight可使用窗口高度 是怎么计算的?
https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getWindowInfo.html [图片] 屏幕高度是667 , wx.getWindowInfo().windowHeight 打出来是 603 ,wx.getWindowInfo().statusBarHeight =20(电量这一栏的高度?) 667 - 20 =647 <不等于> 603 ,是减胶囊高度吗?话说胶囊怎么获得,有文档说这块吗?
2024-12-09 - 这是canvas 一个bug ?
[图片] [图片] scroll-view 里面放一个canvas , 画了一个图形,如上面红色的方块,下拉时canvas图形不会随着scroll-view 移动,看起来很奇怪。
2024-12-06 - 把canvas 和ctx 当作参数传给别的组件
https://developers.weixin.qq.com/miniprogram/dev/framework/ability/canvas.html wx.createSelectorQuery() .select('#myCanvas') // 在 WXML 中填入的 id .fields({ node: true, size: true }) .exec((res) => { // Canvas 对象 const canvas = res[0].node // 渲染上下文 const ctx = canvas.getContext('2d') }) canvas 对象只能在回调函数里获取,那这样没办法把canvas 和ctx 当作参数传给别的组件, 比如<post ctx="{{ctx}}" canvas="{{canvas}}" .../> ,收于是异步初始化,传过去是个空对象,除了同步API, 这个问题怎么解??
2024-12-06