首页 > 微信 > 详细

个人信息——头像更换(拍照或相册上传)~ 微信小程序

时间:2019-02-19 15:59:54      阅读:264      评论:0      收藏:0      [点我收藏+]

微信小程序中 在用户信息中关于用户头像更换(拍照或相册上传)功能实现。

图像点击触发事件:

<image src=‘{{personImage}}‘ bindtap=‘changeAvatar‘ ></image>
Page({
 data:{},  changeAvatar:function(){ const _this = this; wx.chooseImage({ count: 1, sizeType: [‘original‘, ‘compressed‘], sourceType: [‘album‘, ‘camera‘], success(res) { // tempFilePath可以作为img标签的src属性显示图片 const tempFilePath = res.tempFilePaths[0]; _this.setData({ personImage: tempFilePath }) wx.uploadFile({ url: config.UPLOADFILE, //图片上传至开发服务器接口 filePath: tempFilePath, name: ‘file‘, formData: {}, success(res) { const data = res.data; console.log(data); } }) } }) } })

 

个人信息——头像更换(拍照或相册上传)~ 微信小程序

原文:https://www.cnblogs.com/DreamerLeaf/p/10401479.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!