我的小程序设置了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)
}
})
}
}
我是小白,他一改我有点懵。代码部分其实还有其他功能,不过我就挑了我想要的头像和名字
如果小程序更新了我该怎么适配呢