tui-grid-item.vue
2.53 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
<view class="tui-grid" :class="[bottomLine?'':'tui-grid-bottom',border?'':'tui-grid__unlined','tui-grid-'+(cell<2?3:cell)]" :hover-class="hover?'tui-item-hover':''"
:hover-stay-time="150" :style="{backgroundColor:backgroundColor}" @tap="handleClick">
<view class='tui-grid-bg'>
<slot></slot>
</view>
</view>
</template>
<script>
export default {
name: "tuiGridItem",
emits: ['click'],
props: {
cell: {
type: [Number,String],
default: 3
},
backgroundColor: {
type: String,
default: "#fff"
},
//是否有点击效果
hover: {
type: Boolean,
default: true
},
//是否需要底部线条
bottomLine: {
type: Boolean,
default: true
},
//是否需要纵向边框线条
border:{
type: Boolean,
default: true
},
index: {
type: Number,
default: 0
}
},
methods: {
handleClick() {
this.$emit('click', {
index: this.index
});
}
}
}
</script>
<style scoped>
.tui-grid {
position: relative;
padding: 40rpx 20rpx;
box-sizing: border-box;
background: #fff;
float: left;
}
/* #ifdef MP-BAIDU */
.tui-grid:active{
background-color: #f7f7f9;
}
/* #endif */
.tui-grid-2 {
width: 50%;
}
.tui-grid-3 {
width: 33.333333333%;
}
.tui-grid-4 {
width: 25%;
padding: 30rpx 20rpx !important;
}
.tui-grid-5 {
width: 20%;
padding: 20rpx !important;
}
.tui-grid-2:nth-of-type(2n)::before {
width: 0;
border-right: 0;
}
.tui-grid-3:nth-of-type(3n)::before {
width: 0;
border-right: 0;
}
.tui-grid-4:nth-of-type(4n)::before {
width: 0;
border-right: 0;
}
.tui-grid-5:nth-of-type(5n)::before {
width: 0;
border-right: 0;
}
.tui-grid::before {
content: " ";
position: absolute;
right: 0;
top: 0;
width: 1px;
bottom: 0;
border-right: 1px solid #eaeef1;
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
-webkit-transform: scaleX(0.5);
transform: scaleX(0.5);
}
.tui-grid__unlined::before{
width: 0 !important;
border-right: 0 !important;
}
.tui-grid::after {
content: " ";
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 1px;
border-bottom: 1px solid #eaeef1;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.tui-grid-bottom::after {
height: 0 !important;
border-bottom: 0 !important
}
.tui-grid-bg {
position: relative;
padding: 0;
width: 100%;
box-sizing: border-box;
}
.tui-item-hover {
background-color: #f7f7f9 !important;
}
</style>