收藏
回答

canvas 2d selectQuery 后 exec 真机不执行回调?

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug exec 微信安卓客户端 7.0.4.501 2.9.2

<block wx:if="{{item.blank}}">

<canvas id="canvas{{index}}" type="2d">

<cover-view class="canvas"

mark:id="drawboard{{index}}"

mark:cid="canvas{{index}}"

style="width: 350rpx; height: 350rpx;"

bindtouchstart="drawstart"

bindtouchmove="drawing"

bindtouchend="drawend"

bindtouchcancel="drawend"

binderror="drawend"

bind:longpress="clearWord"/>

</canvas>

</block>

let item = this.createSelectorQuery().select(`#canvas${this.blank_index[i]}`).fields({ node: true, size: true, rect: true })

console.log('错误发生前?',item)

item.exec(res => {

console.log(res, '??????')

const { width, height, left, top } = res[0]

const { dpr } = this.data

this[`canvas${this.blank_index[i]}`] = res[0].node

this[`drawboard${this.blank_index[i]}`] = this[`canvas${this.blank_index[i]}`].getContext('2d')

this[`canvas${this.blank_index[i]}`].width = width * dpr

this[`canvas${this.blank_index[i]}`].height = height * dpr

this[`canvas${this.blank_index[i]}`].left = left

this[`canvas${this.blank_index[i]}`].top = top

this[`drawboard${this.blank_index[i]}`].scale(dpr, dpr)

this[`drawboard${this.blank_index[i]}`].lineJoin = "round"

this[`drawboard${this.blank_index[i]}`].lineCap = "round"

this.clearDrawboard(this[`drawboard${this.blank_index[i]}`], this[`canvas${this.blank_index[i]}`])

})


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签