tm-listitem 列表

这是一个非常强大的列表组件

属性众多,依靠强有力的css库,你几乎可以做出时下众多流行漂亮的列表组件。几乎是通用的万能胶列表组件。


动态向列表组tm-grouplist中添加tm-listitem需要使用ref函数inits()重新渲染。静态的无需此动作.
这不是我的问题。在h5是没问题的。但小程序需要调用。因为这是uniapp就不支持子组件的dom更新事件。我也无解。只能这样处理。我个人 建议不需要使用tm-grouplist,因为这个组件,只是动态的帮你设置了下样式而已。


请仔细理解pros属性表和插槽的使用。

🎉目录导航

👉使用方法,跟数1,2,3一样简单


<tm-listitem title="收藏" left-icon="icon-collection-fill" show-left-icon left-icon-color="pink"></tm-listitem>
1

👉完整的示例


可以复制到页面直接运行

<template>
	<view :class="$tm.vx.state().tmVuetify.black ? 'black bk' : ''">
		<tm-menubars title="列表及组" color="bg-gradient-primary-lighten" :showback="true"></tm-menubars>
		<tm-sheet color="blue text"><view class="text-size-s text-weight-b ">基本示例</view></tm-sheet>
		<tm-listitem
			:left-icon-size="80"
			value="打开"
			title="支付"
			label="微信和支付宝微信和支付宝微信和支付宝微信和支付宝"
			left-icon="https://cdn.roundicons.com/wp-content/uploads/2017/09/Lego-freebie-icon.png"
			show-left-icon
		></tm-listitem>
		<tm-listitem title="收藏" left-icon="icon-collection-fill" show-left-icon left-icon-color="pink"></tm-listitem>
		<tm-sheet color="blue text"><view class="text-size-s text-weight-b ">个性化</view></tm-sheet>
		<tm-listitem value="26" :round="24" :shadow="12" title="收藏" left-icon="icon-collection-fill" show-left-icon left-icon-color="pink"></tm-listitem>
		<tm-listitem value="99" :round="3" :shadow="0" border title="支付" left-icon="icon-QQ" show-left-icon></tm-listitem>

		<tm-grouplist title="列表组" title-theme="blue text" :shadow="24" :round="10" :padding="[42, 42]">
			<tm-listitem title="支付" left-icon="icon-QQ" show-left-icon></tm-listitem>
			<tm-listitem title="收藏" left-icon="icon-collection-fill" show-left-icon left-icon-color="pink"></tm-listitem>
			<tm-listitem title="朋友圈" left-icon="icon-user-fill" show-left-icon left-icon-color="green"></tm-listitem>
		</tm-grouplist>
		<tm-grouplist ref="listitem" title="列表组" title-theme="blue text" :shadow="24" :round="10" :padding="[42, 42]">
			<tm-listitem v-for="(item, index) in indexlen" :key="index" title="支付" left-icon="icon-QQ" show-left-icon></tm-listitem>
		</tm-grouplist>
		<view
			class="ma-32 pa-24"
			@click="
				indexlen = indexlen == 4 ? 2 : 4;
				$refs.listitem.inits();
			"
		>
			<tm-button>动态添加列表组件的项目</tm-button>
			<view>动态添加list需要再次,调用ref渲染列表组$refs.listitem.inits()</view>
		</view>
		<tm-grouplist @change="test" title="拓展列表" title-theme="blue text">
			<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
				<template v-slot:group>
					<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text"><view>这里面可以放任意内容、</view></tm-sheet>
				</template>
			</tm-listitem>
			<tm-listitem group title="可以无限级嵌套" left-icon="icon-QQ" show-left-icon>
				<template v-slot:group>
					<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text">
						<view>这里面可以放任意内容、</view>
						<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
							<template v-slot:group>
								<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text">
									<view>这里面可以放任意内容、</view>
									<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
										<template v-slot:group>
											<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text"><view>这里面可以放任意内容、</view></tm-sheet>
										</template>
									</tm-listitem>
								</tm-sheet>
							</template>
						</tm-listitem>
					</tm-sheet>
				</template>
			</tm-listitem>
		</tm-grouplist>

		<tm-listitem group title="也可以独立拓展" left-icon="icon-QQ" show-left-icon>
			<template v-slot:group>
				<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text"><view>这里面可以放任意内容、</view></tm-sheet>
			</template>
		</tm-listitem>

		<tm-grouplist black title="暗黑列表组" title-theme="blue text">
			<tm-listitem black title="支付" left-icon="icon-QQ" show-left-icon></tm-listitem>
			<tm-listitem black title="收藏" left-icon="icon-collection-fill" show-left-icon left-icon-color="pink"></tm-listitem>
			<tm-listitem black title="朋友圈" left-icon="icon-user-fill" show-left-icon left-icon-color="green"></tm-listitem>
		</tm-grouplist>

		<view style="height: 100upx;"></view>
	</view>
</template>
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script>
	export default {
		data() {
			return {
			}
		},
		methods: {
		}
	}
</script>

1
2
3
4
5
6
7
8
9
10
11

👉props属性表

属性名称类型可选值默认值说明
valueString-''右边文字
titleString-''左边标题
title-colorString-'grey-darken-3'标题颜色,暗黑模式下,无效。
font-sizenumber-32标题大小
labelString-''标题下方文字说明
urlString-''打开的链接。不空空时,将会打开链接,如果发生错误,会触发error事件
open-typeStringnavigate / navigateBack /reLaunch / redirect / switchTab'navigate'打开的链接的方式
class-styleString-''自定义类
left-icon-colorString任意主题名称primary左图标主题色
left-iconString任意图标名称或图片地址primary左图标名称,可以是图片地址
right-iconString任意图标名称或图片地址icon-angle-right右图标名称,可以是图片地址
right-icon-colorString任意主题名称primary右图标主题色
bg-colorString任意主题名称''自定义背景色
disabled-colorString任意主题名称''禁用时的背景色
colorString任意主题名称'white'主题色背景色
left-icon-sizeNumber-38左边图标大小
right-icon-sizeNumber-24右边图标大小
roundNumber0-254单位upx, 外部圆角
marginArray<Number>0-25[32,32]单位upx, 外间距
paddingArray<Number>0-25[32,32]单位upx, 内间距
shadowNumber0-506单位upx,投影
denseBooleantrue/falsefalse去除外间距
borderBooleantrue/falsefalse开启边线模式
border-bottomBooleantrue/falsefalse是否显示下划线
blackBooleantrue/falsefalse暗黑模式
show-left-iconBooleantrue/falsefalse是否显示左边图标
show-right-iconBooleantrue/falsetrue是否显示右边图标
groupBooleantrue/falsefalse是否开启拓展功能,点击展开内容。slot:group的内容
disabledBooleantrue/falsefalse是否禁用

👉Slot插槽属性表

属性名称类型数据说明
defaultStringtitle标题数据
labelStringlabel同上方pros的label
leftObjecticon={ icon: leftIcon, color: leftIconColor, fontsize: leftIconSize }左边图标插槽
rightValueStringvalue同上方pros的value
rightIconStringicon同上方pros的value
groupBooleanshow当前pros中启用:group=true,时启用此插槽,并展示拓展内容,具体见示例

👉事件

事件名称返回参数返参类型说明
@changetrue/falseBoolean当group为true时才会触发事件,显示和隐藏扩展内容。
@click--点击组件时触发。
@error错误信息-当url不为空时,打开出错时发出。

👉列表组属性及参数

特别提醒

它不能单独使用,必须和tm-listitem配合使用。


如果你想在列表组在通过v-if来控制listitem这样做是不明智的。你应该改用v-show。

技巧

(可嵌套使用)需要配合tm-listitem使用,可以无限制嵌套
用法见上方示例。

props属性表

属性名称类型可选值默认值说明
titleString-''标题
title-themeString-'primary'标题的主题色彩名
marginNumber0-5032单位upx,外间距
shadowNumber0-2510单位upx,投影
roundNumber0-254单位upx, 外部圆角
blackBooleantrue/falsefalse暗黑模式
border-bottomBooleantrue/falsetrue是否显示底边线
font-sizeStringxxs/xs/s/n/g/lg/xln标题大小

事件

事件名称返回参数返参类型说明
@changeIndexNumber点击了列表。

基础示例

<tm-grouplist @change="test" title="拓展列表" title-theme="blue text">
	<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
		<template v-slot:group>
			<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text"><view>这里面可以放任意内容、</view></tm-sheet>
		</template>
	</tm-listitem>
	<tm-listitem group title="可以无限级嵌套" left-icon="icon-QQ" show-left-icon>
		<template v-slot:group>
			<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text">
				<view>这里面可以放任意内容、</view>
				<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
					<template v-slot:group>
						<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text">
							<view>这里面可以放任意内容、</view>
							<tm-listitem group title="点击我可以展开内容" left-icon="icon-QQ" show-left-icon>
								<template v-slot:group>
									<tm-sheet :margin="[0, 0]" :shadow="0" color="blue text"><view>这里面可以放任意内容、</view></tm-sheet>
								</template>
							</tm-listitem>
						</tm-sheet>
					</template>
				</tm-listitem>
			</tm-sheet>
		</template>
	</tm-listitem>
</tm-grouplist>
 

























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
<script>
	export default {
		data() {
			return {
			}
		},
		methods: {
			test(e){
				console.log(e);
			}
		}
	}
</script>








 
 
 




1
2
3
4
5
6
7
8
9
10
11
12
13
14

👉更新日志

2021年8月20日14:8:5 初始版本。

tmzdy 于 2022/12/7 编辑 报错? | 评论?