如何等待并在Bootstrap Vue中相应地填充数据?

时间:2018-08-14 08:55:17

标签: javascript twitter-bootstrap vue.js promise

我正在使用Bootstrap Vue Table。我正在等待数据到达并据此进行填充。为了获取和存储数据,我使用的是Vuex!

我面临的问题是<b-table>的提供者功能并不真正等待数据到达,而是立即显示空的。

这是我的代码:

<b-table class="table-lg fa-sort-icons table-rounded mt-3 mb-0" :items="fetchAllUsers" :fields="fields"></b-table>

方法:

fetchAllUsers(ctx) {

  this.$store.dispatch(types.GET_CREATED_USERS_ASYNC)

  return this.getAllUsers // this is a getter from vuex(mapGetter) which gets all the users
},

我使用了诺言,但这并没有真正的帮助:

let promise = new Promise((resolve, reject) => {
    if(Object.keys(this.getAllUsers).length > 0) {
        resolve(this.getAllUsers)
    } else {
        reject(this.getAllUsers)
    }
})

promise.then((data) => console.log(data))

0 个答案:

没有答案