【发布时间】:2022-01-09 21:53:07
【问题描述】:
我正在使用 vue 挂载的生命周期方法来获取数据。数据存储在 algolia 中。我使用搜索 api 连接并获取它。仅当我刷新站点时才加载数据。它不在页面导航上运行。
methods: {
async fetchInventory(data = {}) {
try {
this.isLoading = true;
const result = await index.search("", {hitsPerPage: 12});
this.auctions = result.hits;
this.totalItems = result.nbHits;
this.totalPages = result.nbPages;
this.isLoading = false;
} catch (error) {
this.isLoading = false;
console.log(error);
}
},
},
mounted() {
this.fetchInventory();
}
【问题讨论】: