From c0c7d95c0142d1794305c47ada40792c6d5331a3 Mon Sep 17 00:00:00 2001 From: tjz <415800467@qq.com> Date: Sat, 3 Feb 2018 11:20:05 +0800 Subject: [PATCH] fix --- components/tabs/src/ScrollableTabBarMixin.js | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/components/tabs/src/ScrollableTabBarMixin.js b/components/tabs/src/ScrollableTabBarMixin.js index d872ad5aa..e5e553427 100644 --- a/components/tabs/src/ScrollableTabBarMixin.js +++ b/components/tabs/src/ScrollableTabBarMixin.js @@ -9,24 +9,28 @@ export default { }, data () { + this.offset = 0 return { next: false, prev: false, - offset: 0, } }, mounted () { - this.updatedCal() - const debouncedResize = debounce(() => { - this.setNextPrev() - this.scrollToActiveTab() - }, 200) - this.resizeEvent = addDOMEventListener(window, 'resize', debouncedResize) + this.$nextTick(() => { + this.updatedCal() + const debouncedResize = debounce(() => { + this.setNextPrev() + this.scrollToActiveTab() + }, 200) + this.resizeEvent = addDOMEventListener(window, 'resize', debouncedResize) + }) }, updated () { - this.updatedCal() + this.$nextTick(() => { + this.updatedCal() + }) }, beforeDestroy () { @@ -36,11 +40,18 @@ export default { }, watch: { tabBarPosition (val) { - this.setOffset(0) + this.tabBarPositionChange = true + this.$nextTick(() => { + this.setOffset(0) + }) }, }, methods: { updatedCal () { + if (this.tabBarPositionChange) { + this.tabBarPositionChange = false + return + } this.setNextPrev() this.$nextTick(() => { this.scrollToActiveTab()