@kaiyinchem/ky-uniui 1.1.11 → 1.1.13

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.
@@ -10,9 +10,10 @@
10
10
  card: type === 'card',
11
11
  'white-bg': !noBg
12
12
  }"
13
+ :id="`ky-tab-wrap-${id}`"
13
14
  class="ky-tab-wrap"
14
15
  >
15
- <view id="ky-tab-parent" class="ky-tab-components">
16
+ <view class="ky-tab-components">
16
17
  <view class="ky-tab-box">
17
18
  <view
18
19
  v-for="(tab, i) in menu"
@@ -29,7 +30,12 @@
29
30
  </view>
30
31
  <view
31
32
  v-if="tabItemWidth > 0 && !hasIcon"
32
- :style="{ left: tabItemOffsetLeft + 'px', width: tabItemWidth + 'px', 'background-color': activeColor }"
33
+ :style="{
34
+ left: tabItemOffsetLeft + 'px',
35
+ width: tabItemWidth + 'px',
36
+ height: tabItemHeight + 'px',
37
+ 'background-color': activeColor
38
+ }"
33
39
  class="ky-tab-slider"
34
40
  >
35
41
  </view>
@@ -42,6 +48,10 @@
42
48
  emits: ['update:value', 'change'],
43
49
  props: {
44
50
  // 显示字体图标传入icon: '\'
51
+ id: {
52
+ type: [String, Number],
53
+ default: 1
54
+ },
45
55
  menu: {
46
56
  type: Array,
47
57
  default: () => [],
@@ -98,6 +108,7 @@
98
108
  return {
99
109
  tabItemOffsetLeft: 0,
100
110
  tabItemWidth: 0,
111
+ tabItemHeight: 2,
101
112
  tabIndex: 0,
102
113
  }
103
114
  },
@@ -123,27 +134,43 @@
123
134
  },
124
135
  methods: {
125
136
  onTabClick(item, index) {
137
+ this.$nextTick(() => {
138
+ const query = uni.createSelectorQuery().in(this)
139
+ query.select(`#ky-tab-wrap-${this.id}`).boundingClientRect()
140
+ query.select(`#ky_tab_${index}`).boundingClientRect()
141
+ query.exec(data => {
142
+ const parent = data[0]
143
+ const tab = data[1]
144
+ this.tabItemWidth = tab.width
145
+ this.tabItemOffsetLeft = tab.left - parent.left
146
+ if (this.type === 'card') {
147
+ this.tabItemHeight = tab.height
148
+ }
149
+ })
150
+ })
126
151
  if (this.disabled) {
127
152
  return
128
153
  }
129
- if (this.hasIcon) {
130
- this.tabIndex = index
131
- this.$emit('change', index)
132
- this.$emit('update:value', index)
133
- return
134
- }
135
- const query = uni.createSelectorQuery().in(this)
136
- const parent = query.select(`#ky_tab_${index}`)
137
- parent.boundingClientRect(data => {
138
- this.tabItemWidth = data.width
139
- this.tabItemOffsetLeft = data.left
140
- if (this.tabIndex === index) {
141
- return
142
- }
143
- this.tabIndex = index
144
- this.$emit('change', index)
145
- this.$emit('update:value', index)
146
- }).exec()
154
+ if (this.tabIndex === index) {
155
+ return
156
+ }
157
+ this.tabIndex = index
158
+ this.$emit('change', index)
159
+ this.$emit('update:value', index)
160
+ // tabEl.boundingClientRect(data => {
161
+ // console.log(data)
162
+ // this.tabItemWidth = data.width
163
+ // this.tabItemOffsetLeft = data.left
164
+ // if (this.type === 'card') {
165
+ // this.tabItemHeight = data.height
166
+ // }
167
+ // if (this.tabIndex === index) {
168
+ // return
169
+ // }
170
+ // this.tabIndex = index
171
+ // this.$emit('change', index)
172
+ // this.$emit('update:value', index)
173
+ // }).exec()
147
174
  }
148
175
  }
149
176
  }
@@ -184,13 +211,12 @@
184
211
  justify-content: center;
185
212
  border-right: 1px solid var(--color-primary);
186
213
  box-sizing: border-box;
187
- &:last-child {
188
- border-right: 0;
189
- }
190
214
  &.active {
191
- background: var(--color-primary);
192
215
  color: #ffffff;
193
216
  }
217
+ &:last-child {
218
+ border-right: 0;
219
+ }
194
220
  }
195
221
  }
196
222
  }
@@ -223,6 +249,8 @@
223
249
  margin: 0 12rpx;
224
250
  padding: 15rpx 0;
225
251
  transition: all 0.3s;
252
+ position: relative;
253
+ z-index: 1;
226
254
  color: var(--color-gray);
227
255
  &.active {
228
256
  font-weight: bold;
@@ -247,11 +275,11 @@
247
275
  .ky-tab-slider {
248
276
  position: absolute;
249
277
  background-color: var(--color-primary);
250
- height: 6rpx;
251
- border-radius: 12rpx;
252
- width: 50rpx;
253
- bottom: 0;
278
+ height: 0;
279
+ width: 0;
280
+ bottom: 1px;
254
281
  transition: all 0.3s;
282
+ z-index: -1;
255
283
  }
256
284
  }
257
285
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "locale"
10
10
  ],
11
11
  "description": "an uniapp ui",
12
- "version": "1.1.11",
12
+ "version": "1.1.13",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/yezipi/ky-uniui.git"