canvas 2d selectQuery 后 exec 真机不执行回调?
发布于 5 年前 作者 qiangma 8797 次浏览 来自 官方Issues

<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]}`])

})

1 回复

麻烦你先去文档看看再来发帖子吧

回到顶部