当前位置:网站首页>Wechat applet avatarcropper avatar clipping
Wechat applet avatarcropper avatar clipping
2022-07-26 09:27:00 【44w0】
Recently, I'm developing wechat applet , In order to avoid uploading too large user avatars , Lead to waste of resources , Added the function of head image clipping
Use u-View In the component library AvatarCropper Head cut
The official website has made it very clear , The following is the official website address :
https://www.uviewui.com/components/avatarCropper.html
I directly use the code on the official website , I found some problems :
this.$u.route Jump invalid , I'll switch to uniapp Of uni.navigateTo, change to the use of sth. uni.navigateTo You need to pay attention to , The original parameter writing method is not good ,uni.navigateTo The parameters of are spliced behind the path , Use... Between multiple parameters && separate .
methods{
chooseAvatar() {
uni.navigateTo({
// About this path , See below " matters needing attention "
url: '../../u-avatar-cropper/u-avatar-cropper?rectWidth='+200+'&&destWidth='+200+'&&fileType='+'jpg',
})
},
}
created() {
// Listen for events posted from the clipping page , Get clipping results
uni.$on('uAvatarCropper', path => {
let token = uni.getStorageSync("token");
this.avatar = path;
// You can upload it to the server here
uni.uploadFile({
url: baseUrl + '/users/updateAvatar', // Image upload address
filePath: path,
name: 'avatar',
header: {
Authorization: token
},
complete: (res) => {
console.log(res);
}
});
})
},
边栏推荐
猜你喜欢
随机推荐
微信小程序开发
opencv 类的使用
小程序纪录
[MySQL] detailed explanation of redo log, undo log and binlog (4)
什么是异步操作
(2006, MySQL server has gone away) problem handling
LeetCode三数之和问题
"No input file specified" problem handling
Solve "note: one or more layouts are missing the layout_width or layout_height attributes."
2022 chemical automation control instrument operation certificate test question simulation test platform operation
phpexcel导出emoji符号报错
volatile 靠的是MESI协议解决可见性问题?(上)
[arkit, realitykit] turn pictures into 3D models
Basic use of ArcGIS 4
Under a directory of ext3 file system, subfolders cannot be created, but files can be created
Zipkin installation and use
ZXing简化版,转载
arcgis的基本使用4
wap端微信h5支付,用于非微信浏览器
语音聊天app源码——钠斯直播系统源码

![[MySQL] detailed explanation of MySQL lock (III)](/img/3c/c6b5aa5693e6e7b5730a286d988c82.png)





