@kaiyinchem/ky-uniui 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ky-tab.vue +88 -55
- package/package.json +1 -1
package/components/ky-tab.vue
CHANGED
|
@@ -6,23 +6,24 @@
|
|
|
6
6
|
sticky: position === 'sticky',
|
|
7
7
|
iphonex: $safeBottom > 0 && position === 'fixed',
|
|
8
8
|
icon: hasIcon,
|
|
9
|
-
scroll: scrollX
|
|
9
|
+
scroll: scrollX,
|
|
10
|
+
card: type === 'card'
|
|
10
11
|
}"
|
|
11
|
-
class="tab-
|
|
12
|
+
class="ky-tab-wrap"
|
|
12
13
|
>
|
|
13
|
-
<view id="tab-parent" class="tab-components">
|
|
14
|
-
<view class="tab-box">
|
|
14
|
+
<view id="ky-tab-parent" class="ky-tab-components">
|
|
15
|
+
<view class="ky-tab-box">
|
|
15
16
|
<view
|
|
16
17
|
v-for="(tab, i) in menu"
|
|
17
18
|
:style="{ color: activeColor && i === tabIndex ? activeColor : color }"
|
|
18
19
|
:key="i"
|
|
19
20
|
:class="{ active: i === tabIndex, icon: tab.icon }"
|
|
20
|
-
:id="'
|
|
21
|
-
class="tab-item"
|
|
21
|
+
:id="'ky_tab_'+i"
|
|
22
|
+
class="ky-tab-item"
|
|
22
23
|
@click="onTabClick(tab, i)"
|
|
23
24
|
>
|
|
24
|
-
<text v-if="tab.icon" class="tab-icon iconfont">{{ tab.icon }}</text>
|
|
25
|
-
<text class="tab-text">{{ tab[label] }}</text>
|
|
25
|
+
<text v-if="tab.icon" class="ky-tab-icon iconfont">{{ tab.icon }}</text>
|
|
26
|
+
<text class="ky-tab-text">{{ tab[label] }}</text>
|
|
26
27
|
</view>
|
|
27
28
|
</view>
|
|
28
29
|
<!-- <view
|
|
@@ -78,6 +79,11 @@
|
|
|
78
79
|
type: String,
|
|
79
80
|
default: 'id',
|
|
80
81
|
},
|
|
82
|
+
/** line: 边框样式,card,选项卡样式 */
|
|
83
|
+
type: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: 'line',
|
|
86
|
+
}
|
|
81
87
|
},
|
|
82
88
|
data() {
|
|
83
89
|
return {
|
|
@@ -115,7 +121,7 @@
|
|
|
115
121
|
return
|
|
116
122
|
}
|
|
117
123
|
const query = uni.createSelectorQuery().in(this)
|
|
118
|
-
const parent = query.select('#tab-parent')
|
|
124
|
+
const parent = query.select('#ky-tab-parent')
|
|
119
125
|
// vue3版本在真机上不能同时获取两个元素
|
|
120
126
|
parent.boundingClientRect(data => {
|
|
121
127
|
// console.log(data)
|
|
@@ -134,19 +140,46 @@
|
|
|
134
140
|
</script>
|
|
135
141
|
|
|
136
142
|
<style scoped lang="scss">
|
|
137
|
-
.tab-
|
|
143
|
+
.ky-tab-wrap {
|
|
138
144
|
background: var(--bg-white);
|
|
139
145
|
width: auto;
|
|
140
146
|
&.scroll {
|
|
141
147
|
padding: 0 24rpx;
|
|
142
|
-
.tab-components {
|
|
148
|
+
.ky-tab-components {
|
|
143
149
|
white-space: nowrap;
|
|
144
|
-
.tab-box {
|
|
150
|
+
.ky-tab-box {
|
|
145
151
|
justify-content: flex-start;
|
|
146
152
|
position: relative;
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
}
|
|
156
|
+
&.card {
|
|
157
|
+
.ky-tab-components {
|
|
158
|
+
.ky-tab-box {
|
|
159
|
+
justify-content: space-between;
|
|
160
|
+
border: 1px solid var(--color-primary);
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
border-radius: 6rpx;
|
|
163
|
+
.ky-tab-item {
|
|
164
|
+
flex: 1;
|
|
165
|
+
margin: 0;
|
|
166
|
+
border: 0;
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
border-right: 1px solid var(--color-primary);
|
|
171
|
+
box-sizing: border-box;
|
|
172
|
+
&:last-child {
|
|
173
|
+
border-right: 0;
|
|
174
|
+
}
|
|
175
|
+
&.active {
|
|
176
|
+
background: var(--color-primary);
|
|
177
|
+
color: #ffffff;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
150
183
|
&.icon {
|
|
151
184
|
padding: 12rpx 24rpx;
|
|
152
185
|
}
|
|
@@ -165,50 +198,50 @@
|
|
|
165
198
|
z-index: 999;
|
|
166
199
|
top: 0;
|
|
167
200
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
.ky-tab-components {
|
|
202
|
+
position: relative;
|
|
203
|
+
z-index: 1;
|
|
204
|
+
.ky-tab-box {
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: space-around;
|
|
207
|
+
.ky-tab-item {
|
|
208
|
+
margin: 0 12rpx;
|
|
209
|
+
padding: 12rpx 0;
|
|
210
|
+
transition: all 0.3s;
|
|
211
|
+
color: var(--color-gray);
|
|
212
|
+
border-bottom: 2px solid rgba(255,255,255,0);
|
|
213
|
+
box-sizing: border-box;
|
|
214
|
+
&.active {
|
|
215
|
+
font-weight: bold;
|
|
216
|
+
color: var(--color-primary);
|
|
217
|
+
border-color: var(--color-primary);
|
|
218
|
+
}
|
|
219
|
+
&.icon {
|
|
220
|
+
font-weight: normal;
|
|
221
|
+
.tab-text {
|
|
222
|
+
font-size: 22rpx;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
.tab-icon, .tab-text {
|
|
226
|
+
display: block;
|
|
227
|
+
text-align: center;
|
|
228
|
+
color: inherit;
|
|
229
|
+
}
|
|
230
|
+
.tab-icon {
|
|
231
|
+
font-size: 48rpx;
|
|
232
|
+
}
|
|
186
233
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
.tab-icon {
|
|
199
|
-
font-size: 48rpx;
|
|
200
|
-
}
|
|
234
|
+
}
|
|
235
|
+
.ky-tab-slider {
|
|
236
|
+
position: absolute;
|
|
237
|
+
background-color: var(--color-primary);
|
|
238
|
+
height: 6rpx;
|
|
239
|
+
border-radius: 12rpx;
|
|
240
|
+
width: 50rpx;
|
|
241
|
+
left: 15%;
|
|
242
|
+
bottom: 0;
|
|
243
|
+
transition: all 0.5s;
|
|
201
244
|
}
|
|
202
245
|
}
|
|
203
|
-
|
|
204
|
-
position: absolute;
|
|
205
|
-
background-color: var(--color-primary);
|
|
206
|
-
height: 6rpx;
|
|
207
|
-
border-radius: 12rpx;
|
|
208
|
-
width: 50rpx;
|
|
209
|
-
left: 15%;
|
|
210
|
-
bottom: 0;
|
|
211
|
-
transition: all 0.5s;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
246
|
+
}
|
|
214
247
|
</style>
|