2
我使用axios
與vue.js
來獲取數據爲無限分頁。它工作正常,預計在沒有數據來呈現:如何處理axios中的空響應?
fetchData() {
this.loading = true
this.page++;
axios.get(this.BASE_URL + '/api/jokes/'+'?page='+this.page).then(
response =>
//how to exist if there is no data in the response?
this.jokes = response.data).catch(function (error) {
console.log(error);
});
我不知道如何停止渲染當我們到達最後一頁,也沒有更多的數據,以顯示?我看過docs但找不到我的答案。
這是行不通的。我不想重寫整個功能。當response.data爲空時,請限制您的答案以打破此功能。 – Karlom