滾動到底部分頁實現的原理:
1.監聽滾動事件,滾動到底部100px的時候去請求介面獲取分頁資料
2.將介面返回的資料和頁面原有的資料相加
3.如果當前頁等於總頁數,顯示『沒有更多了』
4.如果一開始就沒有資料,顯示『暫無記錄』
5.滾動的事件要考慮事件節流,不然在滾動的時候一直去計算著滾動高度,耗資源
html
} 沒有更多了
暫無記錄
vue js
export default , ).then( (res) => ).catch (() =>
var later = function () else if (!timeout && options.trailing !== false) {
timeout = settimeout(later, remaining)
return result;
throttled.cancel = function () {
cleartimeout(timeout)
previous = 0
timeout = context = args = null
return throttled;
now: function () {
return new date().gettime();
//初始化監聽事件
initpage : function () {
this.$event.on(this.event_data_flow, (e) => {
if(this.current_page_index === e.total_page){
//如果等於最後一頁,就停止滾動
this.loading = false;
if (e.bill_list instanceof array) {
//將現有頁面的資料和介面返回的資料相加
this.bill_list = this.bill_list.concat(e.bill_list);
return;
mounted() {
this.initpage();
//call scrollhandler when page inited
this.scrollhandler();
vue專案從0開始記錄
1 安裝vue cli 2 通過腳手架進行專案的建立 4 配置第三方ui庫快速開發 如ivew,element ui 5 配置axios 庫 一 安裝vue cli npm install g vue cli 或yarn global add vue cli 安裝完成cmd vue v檢視版本 建立...
從0開始搭建vue移動端
建立專案 全域性安裝vue cli npm install g vue cli 建立專案 vue init webpack vue demo如果出現vue 不是內部或外部命令,也不是可執行的程式 或批處理檔案 在main.js中引入flexible.js檔案 flexible.js function...
從零學起vue(學習筆記1)
1 響應式資料繫結2 組合的檢視組建 3 傳遞引數 1 首先需要宣告掛載點 el demo 2 然後傳資料 data data 實現響應的資料繫結 vm.message 使用object.definedproperty中的setter getter 資料,監控對資料的操作 ie8不相容 mdn 模板...