我是靠谱客的博主 难过篮球,这篇文章主要介绍uniapp cell-list 单元格展示组件可自定义icon 和标题,配合uview2.0使用,现在分享给大家,希望可以做个参考。

可自定义icon 和标题,配合uview2.0使用

组件代码

复制代码
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// 注: 当前image icon 是用的uview2.0 组件 如不需要可删除自行更换img标签 <template> <view class="wrap" v-if="itemList.length > 0"> <view v-for="(item,index) in itemList" :key="index" @click="handleClick(item)" class="wrap_box" :style="{background: item.bg || '#FFF'}"> <view class="wrap_box_img"> <u--image :showLoading="true" :src="item.imgSrc" :width="item.imgWidth || '90rpx'" :height="item.imgHeight || '90rpx'"> </u--image> </view> <view class="wrap_box_list" :style="item.tip ? 'padding-top: 30px' : 'padding-top: 40px'"> <view class="wrap_box_list_title">{{item.title}}</view> <view v-if="item.tip" class="wrap_box_list_tip"> {{item.tip}} </view> </view> <view class="wrap_box_icon" v-if="iconShow"> <u-icon :name="item.iName || 'arrow-right'" :color="item.iColor" :size="item.iSize || 28"></u-icon> </view> </view> </view> </template> <script> /** * itemList => [] * @@param {string} title 主标题 * @@param {string} tip 副标题提示 * @@param {string} imgSrc 图片路径 * @@param {string} bg 当前卡片背景色 * @@param {string} imgWidth 图片宽 默认90rpx * @@param {string} imgHeight 图片高 默认90rpx * @@param {string} iColor icon颜色 * @@param {string} iName icon名称 =》 默认角标 arrow-right * @@param {string} iSize icon大小 =》 默认28 * * @@param {string} iconShow 是否展示icon 默认展示 */ export default { name: 'cellList', props: { itemList: { type: Array, default: () => [] }, iconShow: { type: Boolean, default: true } }, data() { return { } }, methods: { handleClick(e) { this.$emit('cellClick', e) } } } </script> <style lang="scss" scoped> .wrap { padding: 0 15px; padding-top: 60rpx; &_box { display: flex; margin-bottom: 60rpx; height: 210rpx; box-shadow: 0px 0px 17px 0px rgba(99, 147, 255, 0.1000); border-radius: 40rpx; &_img { display: flex; flex-direction: row; align-items: center; margin: 0 30rpx; } &_list { flex: 1; &_title { font-weight: 600; font-size: 16px; color: #333333; padding-bottom: 14rpx; } &_tip { font-size: 14px; font-weight: 400; color: #999999; } } &_icon { width: 80rpx; display: flex; flex-direction: row; align-items: center; padding-left: 40rpx; } } } </style>

数据格式

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 数据格式 const itemList = [{ name: 'resident', title: '我是住户', imgSrc: '/static/home/resident_icon.png' tip: '标题提示' }, { name: 'visitor', title: '我是访客', imgSrc: '/static/home/visitor_icon.png' }, { name: 'worker', title: '我是工作人员', imgSrc: '/static/home/worker_icon.png' }, ]

效果展示

在这里插入图片描述

最后

以上就是难过篮球最近收集整理的关于uniapp cell-list 单元格展示组件可自定义icon 和标题,配合uview2.0使用的全部内容,更多相关uniapp内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部