vue项目中生成二维码,并在二维码下面添加文字描述
就像这样
目前搞的使用Qrcode生成二维码,但是不会添加文字描述。。。
求求大佬,救救孩子吧
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
就像这样
目前搞的使用Qrcode生成二维码,但是不会添加文字描述。。。
求求大佬,救救孩子吧
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
终于搞好了,虽然坑点很多,尤其是刚开始使用下面这种方法生成二维码,
结果在处理canvas的时候,拿不到生成的图片(用后端思路考虑,应该是两个方法是异步执行的,处理canvas的时候,new QRCode()还没有生成二维码),后来终于找到正确的途径了。。。
下面的代码,搬过去就能用
你是想把二维码和描述放到一张图片里吗?如果qrcode不支持的话,你可以生成二维码图片以后用canvas画出来二维码和文字到一个图层。
以前做过类似的。需求是生成的图片里除了二维码还要加文字、装饰等。
总之就是利用qrcode库生成图片,获取到其Image元素,然后新建一个canvas,获取到ctx,用
ctx.drawImage
把图片画进去ctx.fillText
写文字。然后就可以了,毕竟canvas用户是可以长按保存图片的可以参考这个js如何处理如下的事务
demo
找遍了整个百度,没有找到一片canvas萌新使用二维码文字的文章。感谢楼主大恩大德把源码分享,今生没齿难忘~
直接用js生成二维码,不是更简单吗
在线列子