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


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

图像点击触发事件:

<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); } }) } }) } })

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM