Vue条件轮询

问题描述 投票:0回答:1
var page = new Vue({
    el: '#content-page',
    data: {
        token: null
    },

    methods: {},
    mounted: function () {
        //get token object from API
    }
});

该令牌有一个属性syncStatus,可以是inProgresscompleted。我想要一个条件轮询,它将继续调用API,直到syncStatus获得完成的值。

我可以做这样的事情:

var page = new Vue({
    el: '#content-page',
    data: {
        token: null
    },

    methods: {
        //Method-get-token
        //In axios.then if syncStatus is inProgress call this method again
    },
    mounted: function () {
        //get token object from API
        //if syncStatus is inProgress call method-get-token
    }
});

但我认为必须有一些更好的方法来做到这一点。

有什么建议?

javascript vue.js vuejs2
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.