mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import { VantComponent } from '../common/component';
|
|
VantComponent({
|
|
field: true,
|
|
relation: {
|
|
name: 'checkbox',
|
|
type: 'descendant',
|
|
linked: function linked(target) {
|
|
var _this$data = this.data,
|
|
value = _this$data.value,
|
|
disabled = _this$data.disabled;
|
|
target.setData({
|
|
value: value.indexOf(target.data.name) !== -1,
|
|
disabled: disabled || target.data.disabled
|
|
});
|
|
}
|
|
},
|
|
props: {
|
|
value: Array,
|
|
disabled: Boolean,
|
|
max: Number
|
|
},
|
|
watch: {
|
|
value: function value(_value) {
|
|
var children = this.getRelationNodes('../checkbox/index');
|
|
children.forEach(function (child) {
|
|
child.setData({
|
|
value: _value.indexOf(child.data.name) !== -1
|
|
});
|
|
});
|
|
},
|
|
disabled: function disabled(_disabled) {
|
|
var children = this.getRelationNodes('../checkbox/index');
|
|
children.forEach(function (child) {
|
|
child.setData({
|
|
disabled: _disabled || child.data.disabled
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}); |