uniapp+vue3获取微信头像、昵称

1、获取头像、昵称

input设置type="nickname"获取昵称,但是通过v-model无法响应获取,所以@blur获取

button 设置open-type="chooseAvatar"获取头像,运行时点击”获取头像“就会弹出,确定就调用onChooseAvatar方法。

<input type="nickname" id="nickName" class="name1" placeholder="请输入昵称"
									@bindinput="inputChange" v-model="showData.nickname" @blur="getNickName" /> 

<button class="login-btn row f-c" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">

								获取头像
							</button> 

假如在form标签包裹上述input标签,form进行commit就可以获取input数据,但是我这里不通过提交表单形式,采用在input失去光标时候用@blur,createselectquery获取昵称

getNickName(e) {//昵称
				console.log(e)
				var that = this
				uni.createSelectorQuery().in(this)
					.select("#nickName")
					.fields({
						properties: ["value"],
					})
					.exec((res) => {
						const nickName = res?.[0]?.value
						that.showData.nickname=nickName
						console.log('获取昵称', nickName)
						// xxx
					})

			},
onChooseAvatar(e) {//头像
				console.log(e)
				var that = this
				//this.showData.avatarUrl = e.detail.avatarUrl //赋值
			},

2、获取微信地址:uniApp使用uni.chooseAddress()获取微信收货地址-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值