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>
相关推荐
00后程序员张1 天前
iOS 上架费用全解析 开发者账号、App 审核、工具使用与开心上架(Appuploader)免 Mac 成本优化指南
android·macos·ios·小程序·uni-app·cocoa·iphone
前端与小赵1 天前
uni-app开发安卓app时控制屏幕常亮不息屏
android·gitee·uni-app
2501_916008891 天前
HTTPS 请求抓包,从原理到落地排查的工程化指南(Charles / tcpdump / Wireshark / Sniffmaster)
ios·小程序·https·uni-app·wireshark·iphone·tcpdump
xiaohe06011 天前
🥳 Uni ECharts 2.1 发布:正式支持鸿蒙,零成本迁移、全平台兼容、跨端开发零负担!
vue.js·uni-app·echarts
2501_915909062 天前
WebView 调试工具全解析,解决“看不见的移动端问题”
android·ios·小程序·https·uni-app·iphone·webview
2501_915106322 天前
App 怎么上架 iOS?从准备资料到开心上架(Appuploader)免 Mac 上传的完整实战流程指南
android·macos·ios·小程序·uni-app·iphone·webview
行走的陀螺仪2 天前
uni-app + Vue3 实现折叠文本(超出省略 + 展开收起)
前端·javascript·css·uni-app·vue3
小禾青青2 天前
uniapp安卓打包遇到报错:Uncaught SyntaxError: Invalid regular expression: /[\p{L}\p{N}]/
android·uni-app
环信即时通讯云2 天前
实现小程序 uniApp 输入框展示自定义表情包
小程序·uni-app
2501_915921432 天前
iOS 抓不到包怎么办?工程化排查与替代抓包方案(抓包/HTTPS/Charles代理/tcpdump)
android·ios·小程序·https·uni-app·iphone·tcpdump