diff --git a/src/components/scrollBoard/index.vue b/src/components/scrollBoard/index.vue index 1a74fb8..bce06df 100644 --- a/src/components/scrollBoard/index.vue +++ b/src/components/scrollBoard/index.vue @@ -33,19 +33,22 @@ export default { }, watch: { data () { - const { init } = this + const { init, autoScrollHandler } = this + + this.fade = false + this.currentTopIndex = 0 + + autoScrollHandler && clearTimeout(autoScrollHandler) init() } }, methods: { init () { - const { data, autoScrollHandler, getDealAfterData, getCurrentScrollData } = this + const { data, getDealAfterData, getCurrentScrollData } = this if (!data) return - autoScrollHandler && clearTimeout(autoScrollHandler) - getDealAfterData() getCurrentScrollData() @@ -68,14 +71,14 @@ export default { this.scrollData = tempArray - setTimeout(doFade, 1500) + this.autoScrollHandler = setTimeout(doFade, 1500) }, doFade () { const { reGetCurrentScrollData } = this this.fade = true - setTimeout(reGetCurrentScrollData, 1500) + this.autoScrollHandler = setTimeout(reGetCurrentScrollData, 1500) }, reGetCurrentScrollData () { const { getCurrentScrollData, dealAfterData, currentTopIndex } = this