需要用到weapp-qrcode.js,下载https://blog-static.cnblogs.com/files/-tiantian/weapp-qrcode.js,点开链接按 ctrl + s 保存到相应的位置

index.wxml中的代码:
index.wxss中的代码:
.ewm{ background-color: #e8e8e8; display: flex; justify-content: center; align-items: center; width: 680rpx; height: 680rpx; margin: 50rpx auto; } .inpt{ border: 1rpx solid #e8e8e8; width: 620rpx; margin: 30rpx auto; padding: 30rpx; } .btn{ width: 680rpx; }
index.js中的代码:
const app = getApp() let drawQrcode = require("../../utils/weapp-qrcode.js") Page({ data: { //根据这个内容生成二维码的!!! text:"西宫硝子", }, onLoad() { this.ewmChange() }, ewmChange(){ let size = {} size.w = wx.getSystemInfoSync().windowWidth / 750 * 600 size.h = size.w var that = this drawQrcode({ width: size.w, height: size.h, canvasId: 'myQrcode', // ctx: wx.createCanvasContext('myQrcode'), text: that.data.text, // v1.0.0+版本支持在二维码上绘制图片 }) }, ewmText(e){ this.setData({ text: e.detail.value }) }, searchFn(){ this.ewmChange() } })
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/201219.html原文链接:https://javaforall.net
