uniapp修改用户头像、u-view实现单元格右侧显示用户头像、u-cell-item 的自定义内容、自定义插槽无效

修改头像功能实现方法

  • 在使用Vue3时直接使用uview会报错,用不了
  • 解决方法是使用比较流行的vk-uview-ui
  • 使用其u-cell-group组件,设置右侧插槽

使用的ui插件

vk-uview-ui,vk-uview-ui 是 VK 基于 uview-ui 1.8.3 版本改造而来,其本质依然还是 uview-ui,是 VK 的珍藏版,由 VK 维护。

注意点

使用vk-uview-ui里面提供的u-cell-group,发现自定义u-cell-item 的插槽无效

作者在文档中提供的使用方式如下,应该是写错了

csharp 复制代码
<u-cell-group>
	<u-cell-item  title="夕阳无限好" arrow-direction="down">
		<template v-slot:icon>
			<u-icon size="32" name="search"></u-icon>
		</template>
		<template v-slot:rightIcon>
			<u-switch v-model="checked"></u-switch>
		</template>
	</u-cell-item>
	<u-cell-item icon="setting-fill" title="只是近黄昏"></u-cell-item>
</u-cell-group>

<template v-slot:rightIcon>这里应该是<template v-slot:right-icon>

而且他提到"自定义右侧图标内容,需设置arrow为false才起作用"

我发现,就算是没有设置arrow为false,也可以显示出来这个插槽,这样就能在显示头像的的同时,显示出右侧箭头了

代码

html 复制代码
<view class="u-m-t-20">
	<u-cell-group>
		<u-cell-item index=0 icon="rmb-circle" title="头像" @click="goTo">
			<template v-slot:right-icon>
			
<!--这里可以改一下src,改成如下,可实现读取vuex的数据-->
<!-- <image class="avatar" :src="userInfo.avator" mode="aspectFill"> -->
				<image class="avatar" src="/static/icon/image-20240409205822053.png" mode="aspectFill">
				</image>			
			</template>
	</u-cell-group>
</view>
相关推荐
xiaohe06015 小时前
🪀 Uni ECharts:也许是 uni-app 中使用 ECharts 最优雅的解决方案
uni-app
陈不知代码17 小时前
uniapp创建vue3+ts+pinia+sass项目
前端·uni-app·sass
源码_V_saaskw17 小时前
JAVA图文短视频交友+自营商城系统源码支持小程序+Android+IOS+H5
java·微信小程序·小程序·uni-app·音视频·交友
996幸存者21 小时前
uni-app区域选择、支持静态、动态数据
微信小程序·uni-app
ᥬ 小月亮1 天前
Uniapp编写微信小程序,绘制动态圆环进度条
微信小程序·小程序·uni-app
耶啵奶膘1 天前
uniapp+vue3——通知栏标题纵向滚动切换
uni-app
The_era_achievs_hero1 天前
UniappDay03
vue.js·微信小程序·uni-app
游戏开发爱好者82 天前
没有 Mac,如何上架 iOS App?多项目复用与流程标准化实战分享
android·ios·小程序·https·uni-app·iphone·webview
Python大数据分析2 天前
uniapp之微信小程序标题对其右上角按钮胶囊
微信小程序·小程序·uni-app
一只一只妖2 天前
uniapp小程序上传图片并压缩
小程序·uni-app