mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
[improvement] Checkbox: use relation mixin
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
export function ChildrenMixin(parent) {
|
||||
return {
|
||||
inject: [parent],
|
||||
inject: {
|
||||
[parent]: {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
parent() {
|
||||
@@ -18,11 +22,17 @@ export function ChildrenMixin(parent) {
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.parent.children = this.parent.children.filter(item => item !== this);
|
||||
if (this.parent) {
|
||||
this.parent.children = this.parent.children.filter(item => item !== this);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
bindRelation() {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { children } = this.parent;
|
||||
|
||||
if (children.indexOf(this) === -1) {
|
||||
|
Reference in New Issue
Block a user