## 完整代碼
```
<template>
<view>
<view v-for="(item, index) in newsList" class="newslist">{{item}}</view>
<view class="loading">{{loadingText}}</view>
</view>
</template>
<script>
var _self, page = 1, timer = null;
export default {
data:{
newsList:[],
loadingText:'加載中...'
},
onLoad:function(){
_self = this;
this.getnewsList();
},
onPullDownRefresh:function(){
this.getnewsList();
},
onReachBottom:function(){
if(timer != null){
clearTimeout(timer);
}
timer = setTimeout(function(){
_self.getmorenews();
}, 1000);
},
methods:{
getmorenews : function(){
if(_self.loadingText != '' && _self.loadingText != '加載更多'){
return false;
}
_self.loadingText = '加載中...';
uni.showNavigationBarLoading();
uni.request({
url: 'https://demo.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=list1&page='+page,
method: 'GET',
success: function(res){
_self.loadingText = '';
if(res.data == null){
uni.hideNavigationBarLoading();
_self.loadingText = '已加載全部';
return false;
}
page++;
console.log(res);
_self.newsList = _self.newsList.concat(res.data.split('--hcSplitor--'));
_self.loadingText = '加載更多';
uni.hideNavigationBarLoading();
}
});
},
getnewsList : function(){
page = 1;
uni.showNavigationBarLoading();
uni.request({
url: 'https://demo.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=list1&page=1',
method: 'GET',
success: function(res){
page++;
_self.newsList = res.data.split('--hcSplitor--');
uni.hideNavigationBarLoading();
uni.stopPullDownRefresh();
_self.loadingText = '加載更多';
}
});
}
}
}
</script>
<style>
.newslist{padding:10px; line-height:60px; font-size:28px;}
.loading{text-align:center; line-height:80px;}
</style>
```
- 第1講 : 創建項目、部署 VUE 、入口頁面布局
- 第2講,快速開始第一個項目
- 第3講 : uni-app 開發規范及目錄結構
- 第4講 : uni-app 頁面樣式與布局
- 第5講 : uni-app 配置文件 - pages.json
- 第6講 : 配置文件 - manifest.json
- 第7講 : uni-app 頁面生命周期
- 第8講 : uni-app 模板語法 - 數據綁定
- 第9講Class 與 Style 綁定 (動態菜單激活示例)
- 第10講 : uni-app 事件處理、事件綁定、事件傳參
- 第11講 : uni-app 組件 - 基礎組件
- 第12講 : uni-app 組件 - 表單組件
- 第13講 : uni-app 組件 - navigator(導航)及頁
- 第14講 : uni-app 組件 - 媒體組件
- 第15講 : uni-app 組件 - 地圖組件
- 第16講 : uni-app 接口 - 網絡請求
- 第17講 : uni-app 接口 - 從本地相冊選擇圖片或使
- 第18講 : uni-app 上傳(圖片上傳實戰)
- 第19講 : uni-app 接口 - 數據緩存
- 第20講 : uni-app 設備相關
- 第21講 : uni-app 交互反饋
- 第22講 : uni-app 設置導航條
- 第23講 : uni-app 導航(頁面流轉)
- 第24講 : uni-app 下拉刷新
- 第25講 : uni-app 上拉加載更多
- 第26講 : uni-app 第三方登錄(小程序篇)
- 第27講 : uni-app 登錄(h5+ app 篇)
- 第28講 : 自定義組件創建及使用