支付宝小程序 字符串生成二维码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/adley_app/article/details/88839966
const QRCode = require('qrcode');

//axml
<view>
	<image src="{{imgSrc}}"  style="width:100%;" mode="aspectFit" />
</view>

// js
Page({
  data: {
    imgSrc: ''"
  },
  onReady(){
     let _this = this;
     
     QRCode.toString('this is string',{type: 'svg'}, function (err, url) {
      let str = 'data:image/svg+xml;base64,' + Buffer(url).toString('base64');
      console.log(str);

      _this.setData({
        imgSrc: str
      })
     });
 }
 });

猜你喜欢

转载自blog.csdn.net/adley_app/article/details/88839966
今日推荐