optmization for update data

This commit is contained in:
jiaming 2018-12-08 19:16:30 +08:00
parent adb33f9326
commit 097b2670d7
1 changed files with 9 additions and 6 deletions

View File

@ -33,19 +33,22 @@ export default {
}, },
watch: { watch: {
data () { data () {
const { init } = this const { init, autoScrollHandler } = this
this.fade = false
this.currentTopIndex = 0
autoScrollHandler && clearTimeout(autoScrollHandler)
init() init()
} }
}, },
methods: { methods: {
init () { init () {
const { data, autoScrollHandler, getDealAfterData, getCurrentScrollData } = this const { data, getDealAfterData, getCurrentScrollData } = this
if (!data) return if (!data) return
autoScrollHandler && clearTimeout(autoScrollHandler)
getDealAfterData() getDealAfterData()
getCurrentScrollData() getCurrentScrollData()
@ -68,14 +71,14 @@ export default {
this.scrollData = tempArray this.scrollData = tempArray
setTimeout(doFade, 1500) this.autoScrollHandler = setTimeout(doFade, 1500)
}, },
doFade () { doFade () {
const { reGetCurrentScrollData } = this const { reGetCurrentScrollData } = this
this.fade = true this.fade = true
setTimeout(reGetCurrentScrollData, 1500) this.autoScrollHandler = setTimeout(reGetCurrentScrollData, 1500)
}, },
reGetCurrentScrollData () { reGetCurrentScrollData () {
const { getCurrentScrollData, dealAfterData, currentTopIndex } = this const { getCurrentScrollData, dealAfterData, currentTopIndex } = this