@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.
@@ -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"
@@ -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
- if (this.hasIcon) {
136
- this.tabIndex = index
137
- this.$emit('change', index)
138
- this.$emit('update:value', index)
139
- return
140
- }
141
- const query = uni.createSelectorQuery().in(this)
142
- const parent = query.select(`#ky_tab_${index}`)
143
- parent.boundingClientRect(data => {
144
- this.tabItemWidth = data.width
145
- this.tabItemOffsetLeft = data.left
146
- if (this.type === 'card') {
147
- this.tabItemHeight = data.height
148
- }
149
- if (this.tabIndex === index) {
150
- return
151
- }
152
- this.tabIndex = index
153
- this.$emit('change', index)
154
- this.$emit('update:value', index)
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
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "locale"
10
10
  ],
11
11
  "description": "an uniapp ui",
12
- "version": "1.1.12",
12
+ "version": "1.1.13",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/yezipi/ky-uniui.git"