自学内容网 自学内容网

小程序之获取用户头像与昵称

html

这个是通过一个点击事件进行显示的,下面是效果图,获取头像最关键的是 open-type="chooseAvatar" ,获取昵称最关键的是 type="nickname" ,大家多加注意i哦

  <!-- 大的输入调取 -->
  <view class="myis_box"  wx:if="{{showMyisBox}}" >
    <!-- 头像 -->
    <view class="myicon_box" style="position: relative;">
      <image src="{{avatarUrl || 'http://lzh.yzwdblzs.xyz/wjqyimg/8393e56638c82f5f4c3662f215f9089b.png'}}" class="myicon" />
      <button style="position: absolute; width: 60px; height: 60px; opacity: 0;" open-type="chooseAvatar" bindchooseavatar="chooseavatar">测试</button>
    </view>
    <!-- 昵称 -->
    <view class="myname">
      <view style="margin-right: 30px;">昵称</view>
      <input type="nickname" class="weui-input" name="nickname" placeholder="请输入昵称"/>
    </view>
    <!-- 点击提交 -->
    <button style="background-color: #07c160;color: white; width: 80%;margin-left: 10%;position: fixed;bottom: 20px;"  bind:tap="submits">提交</button>
  </view>

js

  // 回显图片
  chooseavatar(e) {
    this.setData({
      avatarUrl: e.detail.avatarUrl
    });
  }


原文地址:https://blog.csdn.net/weixin_58462329/article/details/142861261

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!