微信小程序获取头像信息必须使用点击按钮来获取,这个实际也是,只是想法思路不一样,我们可以把背景设置成透明,当用户点击屏幕触发按钮,这里构建一个透明按钮,宽高通过获取手机界面宽高,来赋予。
let sysInfo = wx.getSystemInfoSync();
// 获取微信界面大小
let screenWidth = sysInfo.screenWidth;
let screenHeight = sysInfo.screenHeight;
const wxLoginBtn = wx.createUserInfoButton({
type: 'text',
text: '',
style: {
left: 0,
top: 0,
width: screenWidth,
height: screenHeight,
lineHeight: 40,
backgroundColor: '#00000000',
color: '#ffffff',
textAlign: 'center'
}
})
wxLoginBtn.onTap((res) => {
console.log(res.userInfo)
})
关于简忆
简忆诞生的故事



粤ICP备16092285号
文章评论(0)