注:vue-infinite-loading2.0只能在Vue.js2.0中使用。若是你想在Vue.js1.0中使用,請安裝vue-infinite-loading1.3版本vue
npm install vue-infinite-loading --save
import InfiniteLoading from 'vue-infinite-loading';
export default {
components: {
InfiniteLoading,
},
};
基礎佈局例子:es6
<infinite-loading v-on:infinite="droplist" ref="infiniteLoading" spinner="bubbles"><span style="font-size:20px;" slot="no-more">沒有更多數據了!</span></infinite-loading>
1 droplist: function ($state) { 5 this.$http.get('接口',{ 參數}).then((response) => { 6 if('order_data' in response.data.data){
//this.orderData 是聲明的數組變量,用於存數據 9 this.orderData =this.orderData.concat(response.data.data.order_data) 10 $state.loaded() 11 } else { 12 $state.complete() 13 } 14 }) 22 }