赞
踩
在微信小程序开发过程,我们都会获取当前登录用户微信信息作为个人中心展示信息,例如头像、昵称等。在这个时候,一般处理的方式都是调用API wx.getUserInfo 来获取,此时,便需要弹出用户授权后方可使用,在某方面来说,过于繁琐和用户体验感不是很好。
在微信小程序中,有一个开放功能 open-data 可以帮助我们跳过这些步骤后,显示头像、昵称。
官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/component/open-data.html
<open-data type="userAvatarUrl"></open-data> <open-data type="userNickName"></open-data>
这要便可展示出头像和昵称。
当你使用了上面的写法后, 你后发现 你给这个标签使用的style 和class 属性,编辑他的样式会不生效。解决方式如下:
- <view class='user'>
- <view class='user-avatar'>
- <open-data type='userAvatarUrl'></open-data>
- </view>
- <view class='user-name'>
- <open-data type='userNickName'></open-data>
- </view>
- </view>
需要使用一个view 包裹后 书写样式!
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。