微信小程序动态生成二维码的实现代码

效果图如下:

实现

wxml

rush:js;"> etoFill" src="{{imagePath}}"> Box">

wxss

rush:js;"> .container { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; } .container image { width: 686rpx; height: 686rpx; background-color: #f9f9f9; } .canvas-Box { position: fixed; top: 999999rpx; left: 0; }

js

{ this.canvasToTempImage(); },1000); },/** * 获取临时缓存照片路径,存入data中 */ canvasToTempImage: function() { var that = this; //把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径。 wx.canvasToTempFilePath({ canvasId: 'mycanvas',success: function(res) { var tempFilePath = res.tempFilePath; console.log(tempFilePath); that.setData({ imagePath: tempFilePath,// canvasHidden:true }); },fail: function(res) { console.log(res); } }); },/** * 点击图片进行预览 */ previewImg: function (e) { var img = this.data.imagePath; console.log(img); wx.previewImage({ current: img,// 当前显示图片的http链接 urls: [img] // 需要预览的图片http链接列表 }); },})

qrcode.js 可以去 这里 下载。

详细源码请查看 https://github.com/demi520/wxapp-qrcode

总结

以上所述是小编给大家介绍的微信小程序动态生成二维码的实现代码。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持

相关文章

开发微信小程序的用户授权登录功能
小程序开发页面如何实现跳转?
浅谈小程序开发中蓝牙连接错误分析及解决方法
什么是小程序?它有哪些功能?
如何配置小程序开发项目结构?(教程)
怎么把自己的店加入小程序