uview-plus 3.1.10 → 3.1.12
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
|
@@ -73,7 +73,12 @@
|
|
|
73
73
|
activeColor: null,
|
|
74
74
|
inactiveColor: null,
|
|
75
75
|
size: 18,
|
|
76
|
+
// #ifdef VUE2
|
|
76
77
|
value: null,
|
|
78
|
+
// #endif
|
|
79
|
+
// #ifdef VUE3
|
|
80
|
+
modelValue: null,
|
|
81
|
+
// #endif
|
|
77
82
|
iconColor: null,
|
|
78
83
|
placement: 'row',
|
|
79
84
|
borderBottom: false,
|
|
@@ -183,12 +188,18 @@
|
|
|
183
188
|
if (!this.parent) {
|
|
184
189
|
uni.$u.error('u-checkbox必须搭配u-checkbox-group组件使用')
|
|
185
190
|
}
|
|
191
|
+
// #ifdef VUE2
|
|
192
|
+
const value = this.parentData.value
|
|
193
|
+
// #endif
|
|
194
|
+
// #ifdef VUE3
|
|
195
|
+
const value = this.parentData.modelValue
|
|
196
|
+
// #endif
|
|
186
197
|
// 设置初始化时,是否默认选中的状态,父组件u-checkbox-group的value可能是array,所以额外判断
|
|
187
198
|
if (this.checked) {
|
|
188
199
|
this.isChecked = true
|
|
189
|
-
} else if (uni.$u.test.array(
|
|
200
|
+
} else if (uni.$u.test.array(value)) {
|
|
190
201
|
// 查找数组是是否存在this.name元素值
|
|
191
|
-
this.isChecked =
|
|
202
|
+
this.isChecked = value.some(item => {
|
|
192
203
|
return item === this.name
|
|
193
204
|
})
|
|
194
205
|
}
|
|
@@ -42,9 +42,23 @@
|
|
|
42
42
|
// 所以需要手动通知子组件,这里返回一个parentData变量,供watch监听,在其中去通知每一个子组件重新从父组件(u-checkbox-group)
|
|
43
43
|
// 拉取父组件新的变化后的参数
|
|
44
44
|
parentData() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
return [
|
|
46
|
+
// #ifdef VUE2
|
|
47
|
+
this.value,
|
|
48
|
+
// #endif
|
|
49
|
+
// #ifdef VUE3
|
|
50
|
+
this.modelValue,
|
|
51
|
+
// #endif
|
|
52
|
+
this.disabled,
|
|
53
|
+
this.inactiveColor,
|
|
54
|
+
this.activeColor,
|
|
55
|
+
this.size,
|
|
56
|
+
this.labelDisabled,
|
|
57
|
+
this.shape,
|
|
58
|
+
this.iconSize,
|
|
59
|
+
this.borderBottom,
|
|
60
|
+
this.placement,
|
|
61
|
+
];
|
|
48
62
|
},
|
|
49
63
|
bemClass() {
|
|
50
64
|
// this.bem为一个computed变量,在mixin中
|
|
@@ -53,13 +67,16 @@
|
|
|
53
67
|
},
|
|
54
68
|
watch: {
|
|
55
69
|
// 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
|
|
56
|
-
parentData
|
|
70
|
+
parentData: {
|
|
71
|
+
handler() {
|
|
57
72
|
if (this.children.length) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
this.children.map((child) => {
|
|
74
|
+
// 判断子组件(u-checkbox)如果有init方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值)
|
|
75
|
+
typeof child.init === "function" && child.init();
|
|
76
|
+
});
|
|
62
77
|
}
|
|
78
|
+
},
|
|
79
|
+
deep: true,
|
|
63
80
|
},
|
|
64
81
|
},
|
|
65
82
|
data() {
|