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>
相关推荐
吴传逞1 天前
记一次uniapp微信小程序开发scss变量失效的问题
微信小程序·uni-app·scss
2501_915921432 天前
小团队如何高效完成 uni-app iOS 上架,从分工到工具组合的实战经验
android·ios·小程序·uni-app·cocoa·iphone·webview
2501_916008892 天前
uni-app iOS 文件管理与 itools 配合实战,多工具协作的完整流程
android·ios·小程序·https·uni-app·iphone·webview
!win !2 天前
uni-app项目Tabbar实现切换icon动效
小程序·uni-app
xw52 天前
uni-app项目Tabbar实现切换icon动效
前端·uni-app
2501_916007472 天前
uni-app iOS 文件调试常见问题与解决方案:结合 itools、克魔、iMazing 的实战经验
android·ios·小程序·https·uni-app·iphone·webview
豆豆(设计前端)2 天前
使用 Uni-app 打包 外链地址APK 及 iOS 注意事项
ios·uni-app
jingling5552 天前
uniapp | 解决组件样式不生效问题
前端·css·uni-app·html·学习方法
^Rocky2 天前
微信小程序(uniapp)实现连接蓝牙
微信小程序·uni-app·蓝牙连接
2501_915918412 天前
uni-app 项目 iOS 上架踩坑经验总结 从证书到审核的避坑指南
android·ios·小程序·https·uni-app·iphone·webview