vant
This commit is contained in:
1
utils/dist/checkbox-group/index.d.ts
vendored
Normal file
1
utils/dist/checkbox-group/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
39
utils/dist/checkbox-group/index.js
vendored
Normal file
39
utils/dist/checkbox-group/index.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
VantComponent({
|
||||
field: true,
|
||||
relation: {
|
||||
name: 'checkbox',
|
||||
type: 'descendant',
|
||||
linked(target) {
|
||||
this.children = this.children || [];
|
||||
this.children.push(target);
|
||||
this.updateChild(target);
|
||||
},
|
||||
unlinked(target) {
|
||||
this.children = this.children.filter((child) => child !== target);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
max: Number,
|
||||
value: {
|
||||
type: Array,
|
||||
observer: 'updateChildren'
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
observer: 'updateChildren'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateChildren() {
|
||||
(this.children || []).forEach((child) => this.updateChild(child));
|
||||
},
|
||||
updateChild(child) {
|
||||
const { value, disabled } = this.data;
|
||||
child.setData({
|
||||
value: value.indexOf(child.data.name) !== -1,
|
||||
disabled: disabled || child.data.disabled
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
3
utils/dist/checkbox-group/index.json
vendored
Normal file
3
utils/dist/checkbox-group/index.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
1
utils/dist/checkbox-group/index.wxml
vendored
Normal file
1
utils/dist/checkbox-group/index.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<slot />
|
||||
1
utils/dist/checkbox-group/index.wxss
vendored
Normal file
1
utils/dist/checkbox-group/index.wxss
vendored
Normal file
@@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
||||
Reference in New Issue
Block a user