案例二——二维码

疑问点:

1、监听input输入框内容:

bindKeyInput:function(e){
    var that = this;
    console.log(e.detail.value,"输入框内容")

    that.setData({
      //监听输入框事件
      qrtext: e.detail.value
    }) },

如果不知道内容是e.detail.value,先打印出e看一下

2、
在方法中获取data内的数据:

var that = this;
that.data.qrtext

3、
在方法中修改data内的数据:

var that = this;
that.setData({
qrtext: ”
})

在大括号内,一定要用:,而不是=

4、
获取手机屏幕实时像素大小:
index.js

let res = wx.getSystemInfoSync(); //
width: res.windowWidth*660/750,
height: res.windowWidth*660/750,

index.wxml

 <canvas canvas-id='qrcode' style='margin:auto;height:660rpx;width:660rpx;background:#AAA'></canvas>

这里写图片描述

猜你喜欢

转载自blog.csdn.net/gx17864373822/article/details/81077028