uniapp:微信小程序上传头像

在这里插入图片描述

<view class="logo df-aic-jucen">
	<button class="btn-normal" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"></button>
	<image :src="userinfo.head_portrait" mode="" class="img1"></image>
</view>
onChooseAvatar(e){
	console.log(e);
	this.$uploadImage('/api/uploadImage', e.detail.avatarUrl).then(res => {
		console.log('2',res);
		if (res.code == 200) {
			this.new_avatar_url = res.data.path
			this.$http.post('/api/editUserInfo',{
				name:this.userinfo.name,
				head_portrait:this.new_avatar_url ? this.new_avatar_url : this.userinfo.head_portrait
			}).then(res=>{
				if(res.code == 200){
					this.$toast('修改成功')
				}
			})
		}
	})
},

在这里插入图片描述

相关推荐

  1. 程序--注册时获取头像

    2024-07-13 07:56:03       44 阅读
  2. 程序实现图片到服务器

    2024-07-13 07:56:03       55 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 07:56:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 07:56:03       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 07:56:03       58 阅读
  4. Python语言-面向对象

    2024-07-13 07:56:03       69 阅读

热门阅读

  1. c++【入门】计算(a+b)*c的值

    2024-07-13 07:56:03       21 阅读
  2. C++:strcut与class的区别

    2024-07-13 07:56:03       27 阅读
  3. ref和reactive

    2024-07-13 07:56:03       24 阅读
  4. 如何在SQLServer中更改端口

    2024-07-13 07:56:03       23 阅读
  5. Bilibili Android一二面凉经(2024)

    2024-07-13 07:56:03       23 阅读
  6. CollectionUtils的使用

    2024-07-13 07:56:03       21 阅读
  7. hivehook 表血缘与字段血缘的解析

    2024-07-13 07:56:03       25 阅读
  8. 404/400、Flask、WSGI

    2024-07-13 07:56:03       23 阅读