你好请问一下解决了吗,我这也有这个问题
安卓真机测试canvas不显示图片,开发工具、iOS正常,为什么?很简单的测试canvas , 本地选取一张图片,显示在画布上。开发工具、iOS真机正常,安卓真机测试不行,也无报错。安卓机微信8.0.32,基础库2.19.4,真机测试2.0,开发工具最新版。 每一步都执行,都能获取到图片信息,就是到了draw 时不显示。延时执行也不起作用。布局也极简单,一按钮,一图片,一画布。请问可能是什么原因? <view class="container"> <button bindtap="chooseImage">aaaaa</button> <image src="{{avatar}}" style="width: 300rpx;height: 300rpx;background-color: rgb(255, 127, 127);" mode="aspectFit"></image> <canvas type="2d" id="canvas-avatar" style="width: 300rpx;height: 300rpx;background-color: aquamarine;"></canvas> </view> 代码: var myCanvas = null Page({ data: { avatar: '' }, chooseImage() { let that = this; wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album'], sizeType: ['compressed'], success(res) { that.setData({ avatar: res.tempFiles[0].tempFilePath }); //延时 // setTimeout(()=>{ // that.drawCanvas() // },2000) that.drawCanvas() } }) }, //绘制 drawCanvas() { let that = this wx.createSelectorQuery().selectAll('#canvas-avatar').node(res => { myCanvas = res[0].node const ctx1 = myCanvas.getContext('2d') myCanvas.width = 200 myCanvas.height = 200 // ctx1.scale(dpr,dpr) let image = myCanvas.createImage(); let x = 0, y = 0, size_clip = 0; image.src = that.data.avatar; image.onload = function () { if (image.naturalWidth || image.naturalHeight) {//有高宽 if (image.naturalWidth >= image.naturalHeight) { x = (image.naturalWidth - image.naturalHeight) / 2 size_clip = image.naturalHeight } else { y = (image.naturalHeight - image.naturalWidth) / 2 size_clip = image.naturalWidth } console.log('wa', image.naturalWidth, 'ha', image.naturalHeight) } else {//继续求width/height wx.getImageInfo({ src: that.data.avatar, success(res) { if (res.width >= res.height) { x = (res.width - res.height) / 2 size_clip = res.height } else { y = (res.height - res.width) / 2 size_clip = res.width } console.log('w', res.width, 'h', res.height) } }) } ctx1.drawImage(image, x, y, size_clip, size_clip, 0, 0, myCanvas.width, myCanvas.height); } }).exec() }, })
07-11哥们,怎么加载的,有咩有代码片段学习一下
微信开发者工具1.05 加载spine动画 spine3.8版本 报错VM16 WAGame.js:1 TypeError: Cannot read property 'findRegion' of undefined at _class8.newRegionAttachment (spine-core-3.8.min.js:2218) at e.readAttachment (spine-core-3.8.min.js:3910) at e.readSkin (spine-core-3.8.min.js:3880) at e.readSkeletonData (spine-core-3.8.min.js:3811) at v.parseSpineAni (laya.spine.min.js:594) at v.loop (laya.spine.min.js:586) at mi.run (laya.core.min.js:18990) at fi._update (laya.core.min.js:18834) at Ue._updateTimers (laya.core.min.js:15141) at Ue.render (laya.core.min.js:15119)(env: macOS,mg,1.05.2204264; lib: 2.29.2)
06-26大佬,实现了吗现在也在研究这个问题
大佬们 小程序能运行spine动画吗?小程序能运行spine动画吗
06-24