# 封装小纸条列表组件
<template>
<view class="paper-list">
<view class="paper-img">
<image :src="item.userpic" mode="widthFix" lazy-load></image>
</view>
<view class="paper-content">
<view class="paper-nichen">
<view>{{item.username}}</view>
<view>{{item.time}}</view>
</view>
<view class="paper-info">
<view>{{item.data}}</view>
<template v-if="item.noreadnum>0">
<uni-badge class="uni-badge-left-margin" :text="item.noreadnum" type="error" />
</template>
</view>
</view>
</view>
</template>
<script>
import uniBadge from '../../components/uni-badge/uni-badge.vue'
export default {
components: {
uniBadge
},
props: {
item: Object,
index: Number
}
}
</script>
<style lang="less" scoped>
.paper-list {
display: flex;
border-bottom: 1rpx solid #eee;
padding: 20rpx 0;
.paper-img {
width: 100rpx;
height: 100rpx;
margin-right: 20rpx;
flex-shrink: 0;
image {
width: 100%;
border-radius: 50%;
}
}
.paper-content {
flex: 1;
.paper-nichen {
display: flex;
justify-content: space-between;
view {
&:first-child {
font-size: 35rpx;
}
&:last-child {
color: #cbcbcb;
}
}
}
.paper-info {
display: flex;
justify-content: space-between;
view {
&:first-child {
color: #999;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
&:last-child {}
}
}
}
}
</style>
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
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
然后引入
<template>
<view class="paper">
<!-- 小纸条列表 -->
<block v-for="(item, index) in list" :key="index">
<paperList :item="item" :index="index"> </paperList>
</block>
</view>
</template>
<script>
// 小纸条列表组件
import paperList from '../../components/paper/paper-list.vue'
export default {
components: {
paperList
},
data() {
return {
list: [{
userpic: '../../static/demo/userpic/10.jpg',
username: '星城',
time: '10:10',
data: '哈哈哈哈哈哈哈哈哈, 我来也',
noreadnum: 19
},
{
userpic: '../../static/demo/userpic/13.jpg',
username: '星城1',
time: '10:10',
data: '哈哈哈哈哈哈哈哈哈, 我来也',
noreadnum: 9
},
{
userpic: '../../static/demo/userpic/14.jpg',
username: '星城2',
time: '10:10',
data: '哈哈哈哈哈哈哈哈哈, 我来也',
noreadnum: 0
},
{
userpic: '../../static/demo/userpic/11.jpg',
username: '星城44',
time: '10:10',
data: '哈哈哈哈哈哈哈哈哈, 我来也',
noreadnum: 99
},
]
}
},
methods: {
}
}
</script>
<style lang="less" scoped>
.paper {
padding: 0 20rpx;
}
</style>
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
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