当前位置:   article > 正文

uniapp--新昵称头像自动填写_uniapp 昵称和头像的输入

uniapp 昵称和头像的输入

新昵称头像自动填写

主要是看功能,样式不必计较

<template>
	<view class="newlogin">
		<button type="default" class="btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
			<text>头像</text>
			<view class="cu-avatar lg round" :style="'background-image:url('+imgUrl+');'"></view>
		</button>
		<button type="default" class="btn">
			<text>昵称</text>
			<input type="nickname" class="input" placeholder="请输入昵称" @blur="inputData" v-model="nickName" />
		</button>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				imgUrl:'',  // 头像  首先是默认图像,必须先写一个默认头像的地址在自动获取
				nickName: '微信用户'   // 昵称  
			}
		},
		methods:{
			// 微信头像修改
			onChooseAvatar(e){
				const { avatarUrl } = e.detail
				this.imgUrl = avatarUrl
			},
			// 修改昵称
			inputData(e){
				console.log(e)
				this.nickName = e.detail.value
			}
		}
	}
</script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/743487
推荐阅读