mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 09:24:25 +00:00
[Improvement] optimize find parent mixin (#781)
This commit is contained in:
@@ -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>
|
||||
|
Reference in New Issue
Block a user