[bugfix] Tab: random insert order (#1429)

This commit is contained in:
neverland 2018-07-06 20:33:06 +08:00 committed by GitHub
parent 72a88f1954
commit 33cd446581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,19 +49,19 @@ export default create({
created() {
this.findParent('van-tabs');
const { tabs } = this.parent;
const index = this.parent.$slots.default.indexOf(this.$vnode);
tabs.splice(index === -1 ? tabs.length : index, 0, this);
},
mounted() {
const { tabs } = this.parent;
const index = this.parent.$slots.default.indexOf(this.$vnode);
tabs.splice(index === -1 ? tabs.length : index, 0, this);
if (this.$slots.title) {
this.parent.renderTitle(this.$refs.title, this.index);
}
},
destroyed() {
beforeDestroy() {
this.parent.tabs.splice(this.index, 1);
}
});