Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs: fix a 'activeName' attribute init bug #1100

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/tabs/src/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
return {
children: null,
activeTab: null,
currentName: 0
currentName: 0,
inited: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但起来并不需要放在 data 里

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来不放在data里面不会重新渲染

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦 是为了强制触发更新么,有一个 $forceUpdate 方法嘛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

囧 忘了 那删掉好了

};
},

Expand Down Expand Up @@ -72,8 +73,9 @@
}
},
mounted() {
this.currentName = this.activeName || this.$children[0].index || '1';
this.$nextTick(() => {
this.currentName = this.activeName || this.$children[0].index || '1';
this.inited = true;
});
},
render(h) {
Expand Down Expand Up @@ -110,7 +112,7 @@
}, [
tab.label,
closable ? btnClose : null,
index === 0 ? activeBar : null
this.inited && index === 0 ? activeBar : null
]);
return _tab;
});
Expand Down