在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue-countdown倒計(jì)時(shí)無法動(dòng)態(tài)設(shè)置時(shí)間

vue-countdown倒計(jì)時(shí)無法動(dòng)態(tài)設(shè)置時(shí)間

項(xiàng)目中使用vue-countdown來實(shí)現(xiàn)倒計(jì)時(shí),倒計(jì)時(shí)的剩余時(shí)間從api中獲取,但是頁(yè)面中顯示的倒計(jì)時(shí)不會(huì)自動(dòng)更改,代碼如下:

<vue-countdown :time="countDown" :interval="1000" :auto-start="true" ref="countdown" class="count-down">
    <template slot-scope="props">{{ props.days }}天{{ props.hours }}時(shí){{ props.minutes }}分{{ props.seconds }}秒</template>
</vue-countdown>

<script>
import VueCountdown from '@xkeshi/vue-countdown'
export default {
    components: {
        VueCountdown
    },
    data () {
        return {
            countDown: 0
        }
    },
    created: function () {
        axios({
            method: 'GET',
            url: 'http://a.b.c',
            withCredentials: true,
            headers: {'lang': 'zh', 'token': '', 'os': 'web', 'version': '1.0.0', 'time': ''}
        }).then((response) => {
            let responseData = response.data.data
            this.timeLeft = responseData.timeLeft
            let now = new Date()
            let timer = (this.timeLeft + 0) * 1000
            let setNow = new Date(now.getTime() + timer)
            this.countDown = setNow - now
            this.$refs.countdown.init()
            this.$refs.countdown.start()
        }).catch((ex) => {
            console.log(ex)
        })
    }
}
</script>

這樣寫頁(yè)面中能顯示剩余時(shí)間,但是時(shí)間不會(huì)自己改變,上面的代碼中如果直接在return里把countDown的值寫死,并且注釋掉鉤子函數(shù)中的countDown賦值,倒計(jì)時(shí)是沒問題的,官方文檔也沒發(fā)現(xiàn)關(guān)于這個(gè)的描述,感覺應(yīng)該是自己有什么地操作不當(dāng),求大佬指點(diǎn)

回答
編輯回答
青裙

auto-start改為false來試試

2017年4月8日 06:34