uniapp:微信小程序上传头像

html 复制代码
<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>
js 复制代码
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('修改成功')
				}
			})
		}
	})
},
相关推荐
codingWhat12 小时前
小程序里「嵌」H5:一套完整可落地的 WebView 集成方案
前端·uni-app·webview
WangHappy1 天前
不写 Canvas 也能搞定!小程序图片导出的 WebView 通信方案
前端·微信小程序
小时前端2 天前
微信小程序选不了本地文件?用 web-view + H5 一招搞定
前端·微信小程序·uni-app
Mr_li2 天前
给 Vue 开发者的 uni-app 快速指南
vue.js·uni-app
anyup2 天前
🔥2026最推荐的跨平台方案:H5/小程序/App/鸿蒙,一套代码搞定
前端·uni-app·harmonyos
icebreaker2 天前
Weapp-vite:原生模式之外,多一种 Vue SFC 选择
前端·vue.js·微信小程序
icebreaker2 天前
重走 Vue 长征路 Weapp-vite:编译链路与 Wevu 运行时原理拆解
前端·vue.js·微信小程序
Mintopia3 天前
Vue3 项目如何迁移到 uni-app x:从纯 Web 到多端应用的系统指南
uni-app
Mintopia3 天前
uni-app x 发展前景技术分析:跨端统一的新阶段?
uni-app
不爱说话郭德纲4 天前
告别漫长的HbuilderX云打包排队!uni-app x 安卓本地打包保姆级教程(附白屏、包体积过大排坑指南)
android·前端·uni-app