@kaiyinchem/ky-uniui 1.1.12 → 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.
- package/components/ky-tab.vue +40 -22
- package/package.json +1 -1
package/components/ky-tab.vue
CHANGED
|
@@ -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
|
|
16
|
+
<view class="ky-tab-components">
|
|
16
17
|
<view class="ky-tab-box">
|
|
17
18
|
<view
|
|
18
19
|
v-for="(tab, i) in menu"
|
|
@@ -47,6 +48,10 @@
|
|
|
47
48
|
emits: ['update:value', 'change'],
|
|
48
49
|
props: {
|
|
49
50
|
// 显示字体图标传入icon: '\'
|
|
51
|
+
id: {
|
|
52
|
+
type: [String, Number],
|
|
53
|
+
default: 1
|
|
54
|
+
},
|
|
50
55
|
menu: {
|
|
51
56
|
type: Array,
|
|
52
57
|
default: () => [],
|
|
@@ -129,30 +134,43 @@
|
|
|
129
134
|
},
|
|
130
135
|
methods: {
|
|
131
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
|
+
})
|
|
132
151
|
if (this.disabled) {
|
|
133
152
|
return
|
|
134
153
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}).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()
|
|
156
174
|
}
|
|
157
175
|
}
|
|
158
176
|
}
|