需要先创建image对象,提供image.src,image.onload过程中canvasContext.drawImage(image,...) 可参考: https://developers.weixin.qq.com/community/develop/article/doc/000e88e73a415835ed9b46d7956013 小程序官方文档没有诚意吧!
Failed to execute 'drawImage' on 'CanvasRenderin ?Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)';at SelectorQuery callback function TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)'
2021-11-28我也使用weui扩展组件 mp-tabs 在两处不同的页面(1处正常,1处不正常),没有使用searchbar,编译总是报问题。不知道有什么后果。 VM557 WAService.js:formatted:140900 [Component] the type of property "search" is illegal (when preparing behavior "miniprogram_npm/weui-miniprogram/searchbar/searchbar")
npm安装weui-miniprogram编译后老提示searchBar.js或者xxx.js有错?用useExtendedLib 扩展库 的方式引入也试过了,后改为用npm的方式,还是报同样的错误,我是用微信开发者工具里面用终端: 1.npm install weui-miniprogram:生成了node_modules和一个package-lock.json 2.npm init:生成了一个package.json 3.工具-构建npm:生成了一个miniprogram_npm/weui-miniprogram 4.在app.wxss顶上加了 @import '/miniprogram_npm/weui-miniprogram/weui-wxss/dist/style/weui.wxss'; 最后点编译,老是报一些缺胳膊少腿的错误,是什么原因呢,请大佬们看看 [图片]
2021-11-09canvas 的定位决定了位置,只要设好它的居中位置(margin: 0 10%)
关于qrcode二维码布局问题?qrcode1 = new QRCode('canvas', { text: app.globalData.mobile, width:100, height:100, colorDark: "#1CA4FC", colorLight: "white", correctLevel: QRCode.CorrectLevel.H, }); <view class="container"> <block > <View class="QRbackground"> <image src="tttt.jpg"></image> </View> <view class="userinfo-avatar" > <open-data type="userAvatarUrl"></open-data> </view> <canvas class='canvas' canvas-id='canvas' bindlongtap='save'></canvas> </block> .cavas{ position: fixed; top:-400rpx; width :100rpx; height: 100rpx; } .QRbackground image{ position: fixed; top:300rpx; left:75rpx; right:75rpx; width:600rpx; height:600rpx ; }[图片]我想实现这种布局效果,就是二维码要显示在一个白色图片的中央,具体代码已贴,为什么二维码的布局位置总是没效果
2021-11-08