ljhasn 2021-02-26 18:00 采纳率: 33.3%
浏览 98

微信小程序button怎么适配

 

我的小程序设置了button里的open-type="getUserInfo",觉得挺好用的,用来获取添加信息的用户的头像并直接显示出来,他这一改我不会适配了

wxml配置
<button hover-class="none" catchtap="submit" type="warn" plain open-type="getUserInfo"
  bindgetuserinfo="handleGetUserInfo" bindtap="addData">提交申请</button>

js配置
const DB = wx.cloud.database().collection("addlist")
Page({
  data: {
    name: '',
    head: ''
  },
addData: function (e) {
    let that = this
    let name = that.data.name
    let head = that.data.head
that.setData({
      name: name,
      head: head
})
},
  handleGetUserInfo(e) {
    console.log(e.detail.userInfo);
    this.setData({
      name: e.detail.userInfo.nickName,
      head: e.detail.userInfo.avatarUrl
    })
  },
submit: function () {
    let that = this
    let name = that.data.name
    let head = that.data.head
DB.add({
        data: {
          name: name,
          head: head,
        },
        success(res) {
          console.log("添加成功", res)
        },
        fail(res) {
          console.log("添加失败", res)
        }
      })
    }
  }

我是小白,他一改我有点懵。代码部分其实还有其他功能,不过我就挑了我想要的头像和名字

如果小程序更新了我该怎么适配呢

  • 写回答

1条回答 默认 最新

  • L-zbin 2021-02-26 18:41
    关注

    评论

报告相同问题?

悬赏问题

  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件