@kaiyinchem/ky-uniui 1.0.5 → 1.0.6
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 +83 -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,41 @@
|
|
|
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
|
+
&.active {
|
|
171
|
+
background: var(--color-primary);
|
|
172
|
+
color: #ffffff;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
150
178
|
&.icon {
|
|
151
179
|
padding: 12rpx 24rpx;
|
|
152
180
|
}
|
|
@@ -165,50 +193,50 @@
|
|
|
165
193
|
z-index: 999;
|
|
166
194
|
top: 0;
|
|
167
195
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
.ky-tab-components {
|
|
197
|
+
position: relative;
|
|
198
|
+
z-index: 1;
|
|
199
|
+
.ky-tab-box {
|
|
200
|
+
display: flex;
|
|
201
|
+
justify-content: space-around;
|
|
202
|
+
.ky-tab-item {
|
|
203
|
+
margin: 0 12rpx;
|
|
204
|
+
padding: 12rpx 0;
|
|
205
|
+
transition: all 0.3s;
|
|
206
|
+
color: var(--color-gray);
|
|
207
|
+
border-bottom: 2px solid rgba(255,255,255,0);
|
|
208
|
+
box-sizing: border-box;
|
|
209
|
+
&.active {
|
|
210
|
+
font-weight: bold;
|
|
211
|
+
color: var(--color-primary);
|
|
212
|
+
border-color: var(--color-primary);
|
|
213
|
+
}
|
|
214
|
+
&.icon {
|
|
215
|
+
font-weight: normal;
|
|
216
|
+
.tab-text {
|
|
217
|
+
font-size: 22rpx;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
.tab-icon, .tab-text {
|
|
221
|
+
display: block;
|
|
222
|
+
text-align: center;
|
|
223
|
+
color: inherit;
|
|
224
|
+
}
|
|
225
|
+
.tab-icon {
|
|
226
|
+
font-size: 48rpx;
|
|
227
|
+
}
|
|
186
228
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
.tab-icon {
|
|
199
|
-
font-size: 48rpx;
|
|
200
|
-
}
|
|
229
|
+
}
|
|
230
|
+
.ky-tab-slider {
|
|
231
|
+
position: absolute;
|
|
232
|
+
background-color: var(--color-primary);
|
|
233
|
+
height: 6rpx;
|
|
234
|
+
border-radius: 12rpx;
|
|
235
|
+
width: 50rpx;
|
|
236
|
+
left: 15%;
|
|
237
|
+
bottom: 0;
|
|
238
|
+
transition: all 0.5s;
|
|
201
239
|
}
|
|
202
240
|
}
|
|
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
|
-
}
|
|
241
|
+
}
|
|
214
242
|
</style>
|