[Improvement] optimize find parent mixin (#781)

This commit is contained in:
neverland
2018-03-26 21:20:00 +08:00
committed by GitHub
parent dadf733d71
commit 5497eef5ef
13 changed files with 82 additions and 105 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="van-tab__pane" :class="{ 'van-tab__pane--select': index === parentGroup.curActive }">
<div class="van-tab__pane" :class="{ 'van-tab__pane--select': index === parent.curActive }">
<slot />
</div>
</template>
@@ -20,17 +20,17 @@ export default create({
computed: {
index() {
return this.parentGroup.tabs.indexOf(this);
return this.parent.tabs.indexOf(this);
}
},
created() {
this.findParentByName('van-tabs');
this.parentGroup.tabs.push(this);
this.findParent('van-tabs');
this.parent.tabs.push(this);
},
destroyed() {
this.parentGroup.tabs.splice(this.index, 1);
this.parent.tabs.splice(this.index, 1);
}
});
</script>