uview-plus 3.8.126 → 3.8.127
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/changelog.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 3.8.127
|
|
2
|
+
fix: 修复抖音小程序 tabbar-item / steps-item 因父子生命周期顺序导致的崩溃
|
|
3
|
+
|
|
4
|
+
抖音小程序中,子组件的 created 可能早于父组件的 created 执行,此时父组件实例已可通过 $parent 找到,但父组件的 children 数组尚未初始化(u-tabbar / u-steps / u-list 都在自己的 created 里才赋值 children=[])。子组件 init() 直接访问 this.parent.children.indexOf(this) 时 children 仍为 undefined,抛出 TypeError: Cannot read properties of undefined (reading 'indexOf'),并伴随「up-tabbar-item必须搭配up-tabbar组件使用」的误报警告(该分支只 log 未 return,继续执行才崩溃)。对照 u-radio / u-checkbox:它们在 mounted() 调 init() 且不访问 parent.children,所以不受影响。
|
|
5
|
+
|
|
6
|
+
- u-tabbar-item:init() 在 error() 后补 return,并加 !this.parent.children 守卫;mounted() 新增 init() 补偿重试(created 阶段被跳过时补齐激活态);clickHandler() 补 this.parent / children 守卫
|
|
7
|
+
- u-steps-item:init() 加 !this.parent.children 守卫;mounted() 新增 init() 补偿重试,确保自身已注册进父组件 children
|
|
8
|
+
- u-list-item:init() 加 !this.parent / !this.parent.children 守卫,避免 $parent 返回 false 时报错
|
|
9
|
+
- 共享 mixin getParentData():访问 children 前先判断 this.parent 存在,避免 $parent 返回 false 时读取 false.children 崩溃,影响所有父子联动组件
|
|
10
|
+
|
|
1
11
|
## 3.8.126
|
|
2
12
|
feat: 新增 u-flex 通用弹性布局容器组件
|
|
3
13
|
|
|
@@ -187,6 +187,9 @@
|
|
|
187
187
|
}
|
|
188
188
|
},
|
|
189
189
|
mounted() {
|
|
190
|
+
// 抖音小程序等平台子组件 created 可能在父组件 created 之前执行,
|
|
191
|
+
// 此时 parent.children 尚未初始化,init 被跳过,此处补偿重试
|
|
192
|
+
this.init()
|
|
190
193
|
this.parent && this.parent.updateFromChild()
|
|
191
194
|
sleep().then(() => {
|
|
192
195
|
this.getStepsItemRect()
|
|
@@ -199,6 +202,12 @@
|
|
|
199
202
|
if (!this.parent) {
|
|
200
203
|
return error('u-steps-item必须要搭配u-steps组件使用')
|
|
201
204
|
}
|
|
205
|
+
// 抖音小程序等平台子组件 created 可能在父组件 created 之前执行,
|
|
206
|
+
// 此时 parent.children 尚未初始化(u-steps 在 created 中才赋值 children=[]),
|
|
207
|
+
// 跳过本次初始化,由 mounted 钩子补偿重试
|
|
208
|
+
if (!this.parent.children) {
|
|
209
|
+
return
|
|
210
|
+
}
|
|
202
211
|
this.index = this.parent.children.indexOf(this)
|
|
203
212
|
this.childLength = this.parent.children.length
|
|
204
213
|
},
|
|
@@ -239,6 +239,9 @@
|
|
|
239
239
|
this.init()
|
|
240
240
|
},
|
|
241
241
|
mounted() {
|
|
242
|
+
// 抖音小程序等平台子组件 created 可能在父组件 created 之前执行,
|
|
243
|
+
// 此时 parent.children 尚未初始化,init 被跳过,此处补偿重试
|
|
244
|
+
this.init()
|
|
242
245
|
this.scheduleMidButtonBorderMeasure()
|
|
243
246
|
},
|
|
244
247
|
watch: {
|
|
@@ -260,6 +263,13 @@
|
|
|
260
263
|
this.updateParentData()
|
|
261
264
|
if (!this.parent) {
|
|
262
265
|
error('up-tabbar-item必须搭配up-tabbar组件使用')
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
// 抖音小程序等平台子组件 created 可能在父组件 created 之前执行,
|
|
269
|
+
// 此时 parent.children 尚未初始化(u-tabbar 在 created 中才赋值 children=[]),
|
|
270
|
+
// 跳过本次初始化,由 mounted 钩子补偿重试
|
|
271
|
+
if (!this.parent.children) {
|
|
272
|
+
return
|
|
263
273
|
}
|
|
264
274
|
// 本子组件在u-tabbar的children数组中的索引
|
|
265
275
|
const index = this.parent.children.indexOf(this)
|
|
@@ -299,10 +309,11 @@
|
|
|
299
309
|
},
|
|
300
310
|
clickHandler() {
|
|
301
311
|
this.$nextTick(() => {
|
|
312
|
+
if (!this.parent || !this.parent.children) return
|
|
302
313
|
const index = this.parent.children.indexOf(this)
|
|
303
314
|
const name = this.name || index
|
|
304
315
|
// 点击的item为非激活的item才发出change事件
|
|
305
|
-
if (name !== this.parent.value) {
|
|
316
|
+
if (this.parent && name !== this.parent.value) {
|
|
306
317
|
this.parent.$emit('change', name)
|
|
307
318
|
}
|
|
308
319
|
this.$emit('click', name)
|
package/libs/mixin/mixin.js
CHANGED
|
@@ -227,7 +227,7 @@ export const mixin = defineMixin({
|
|
|
227
227
|
// 之所以需要这么做,是因为所有端中,头条小程序不支持通过this.parent.xxx去监听父组件参数的变化
|
|
228
228
|
// 此处并不会自动更新子组件的数据,而是依赖父组件u-radio-group去监听data的变化,手动调用更新子组件的方法去重新获取
|
|
229
229
|
this.parent = $parent.call(this, parentName)
|
|
230
|
-
if (this.parent.children) {
|
|
230
|
+
if (this.parent && this.parent.children) {
|
|
231
231
|
// 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
|
|
232
232
|
this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
|
|
233
233
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "uview-plus",
|
|
3
3
|
"name": "uview-plus",
|
|
4
4
|
"displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙跨端移动组件库,组件丰富维护更新稳定。",
|
|
5
|
-
"version": "3.8.
|
|
5
|
+
"version": "3.8.127",
|
|
6
6
|
"description": "零云®uview-plus已兼容vue3支持多语言,120+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uview",
|