微信小程序> 微信小程序更换头像的实现源码

微信小程序更换头像的实现源码

浏览量:2707 时间: 来源:小吖吖

微信小程序更换头像的实现源码

html

  <view class='top_head_border'>    <image class='top_head' src='{{head}}'></image>   <view class='top_text'  mode="aspecFill" bindtap="headimage">点击更换头像</view> </view>

css

.top_head {  margin-top: 30rpx;  width: 160rpx;   height: 160rpx;   border-radius: 100%;   border: 1px solid rgba(51, 51, 51, 1);       }.top_text {  line-height: 40rpx;   color: rgba(229, 28, 35, 1);   font-size: 28rpx;   font-family: Roboto; }
  data: {       // 切换头像      showModal: false,        head: "/img/1.png",        },       // 点击换手机相册或者电脑本地图片           headimage: function() {             var _this = this;             wx.chooseImage({                   count: 1, // 默认9                      sizeType: ['original', 'compressed'],                         // 指定是原图还是压缩图,默认两个都有                         sourceType: ['album', 'camera'],                        // 指定来源是相册还是相机,默认两个都有                       success: function(res) {                          // 返回选定照片的本地文件路径tempFilePath可以作为img标签的src属性显示图片                    //然后请求接口把图片传给后端存到服务器即可                            _this.setData({                           head: res.tempFilePaths                                                })                                 }                       })       },
微信小程序

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎