tabs 组件修改 (#18)

* 修改tab tabs内部交互逻辑
This commit is contained in:
Yao
2017-04-26 14:34:24 +08:00
committed by GitHub
parent b98a624960
commit 639d3a65c5
3 changed files with 54 additions and 4 deletions

View File

@@ -15,12 +15,21 @@
},
disabled: Boolean
},
beforeCreate() {
this.$parent.tabs.push(this);
data() {
const nextIndex = this.$parent.tabs.length;
this.$parent.tabs.push({
title: this.title,
disabled: this.disabled,
index: nextIndex
});
return {
key: nextIndex
};
},
computed: {
classNames() {
return { 'van-tab__pane--select': this.$parent.tabs.indexOf(this) === this.$parent.curActive };
return { 'van-tab__pane--select': this.key === this.$parent.curActive };
}
}
};