能看的av_午夜黄色av_在线观看国产视频_天天爱综合_国产精品亚洲成在人线_日韩一

訂閱本欄目 RSS您所在的位置: 深山工作室 > uni-app > 正文

uni-app實(shí)現(xiàn)上拉加載,下拉刷新(下拉帶動(dòng)畫)

2020/9/15 15:20:52 字體: 瀏覽 7875

直接展示代碼,uni-app的上拉加載動(dòng)畫

1 . 在pages.json添加允許下拉刷新
    {
        "path":"pages/lookuser/lookuser",
        "style":{
            "navigationBarTitleText":"用戶日志",
            "enablePullDownRefresh": true//就是這個(gè)
        }
    }


2. 上拉加載更多組件
比如把組件放在component下了component/uni-load-more.vue


<template>
<view class="load-more">
<view class="loading-img" v-show="loadingType === 1 && showImage">
<view class="load1">
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
</view>
<view class="load2">
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
</view>
<view class="load3">
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
<view :style="{background:color}"></view>
</view>
</view>
<text class="loading-text" :style="{color:color}">
{{loadingType === 0 ? contentText.contentdown : (loadingType === 1 ? contentText.contentrefresh : contentText.contentnomore)}}</text>
</view>
</template>

<script>
export default {
name: "load-more",
props: {
loadingType: {
//上拉的狀態(tài):0-loading前;1-loading中;2-沒有更多了
type: Number,
default: 0
},
showImage: {
type: Boolean,
default: true
},
color: {
type: String,
default: "#777777"
},
contentText: {
type: Object,
default () {
return {
contentdown: "上拉顯示更多",
contentrefresh: "正在加載...",
contentnomore: "沒有更多數(shù)據(jù)了"
};
}
}
},
data() {
return {}
}
}
</script>

<style>
.load-more{display:flex;flex-direction:row;height:80upx;align-items:center;justify-content:center;}
.loading-img{height:24px;width:24px;margin-right:10px;}
.loading-text{font-size:28upx;color:#777777;}
.loading-img>view{position:absolute;}
.load1,.load2,.load3{height:24px;width:24px;}
.load2{transform:rotate(30deg);}
.load3{transform:rotate(60deg);}
.loading-img>view view{width:6px;height:2px;border-top-left-radius:1px;border-bottom-left-radius:1px;background:#777;position:absolute;opacity:0.2;transform-origin:50%;-webkit-animation:load 1.56s ease infinite;}
.loading-img>view view:nth-child(1){transform:rotate(90deg);top:2px;left:9px;}
.loading-img>view view:nth-child(2){-webkit-transform:rotate(180deg);top:11px;right:0px;}
.loading-img>view view:nth-child(3){transform:rotate(270deg);bottom:2px;left:9px;}
.loading-img>view view:nth-child(4){top:11px;left:0px;}
.load1 view:nth-child(1){animation-delay:0s;}
.load2 view:nth-child(1){animation-delay:0.13s;}
.load3 view:nth-child(1){animation-delay:0.26s;}
.load1 view:nth-child(2){animation-delay:0.39s;}
.load2 view:nth-child(2){animation-delay:0.52s;}
.load3 view:nth-child(2){animation-delay:0.65s;}
.load1 view:nth-child(3){animation-delay:0.78s;}
.load2 view:nth-child(3){animation-delay:0.91s;}
.load3 view:nth-child(3){animation-delay:1.04s;}
.load1 view:nth-child(4){animation-delay:1.17s;}
.load2 view:nth-child(4){animation-delay:1.30s;}
.load3 view:nth-child(4){animation-delay:1.43s;}
@-webkit-keyframes load{0%{opacity:1;}
100%{opacity:0.2;}
}
</style>

3. 在頁面上調(diào)用組件


<template>
    <view style="flex: 1;">
<view v-for="(item, index) in newsList" class="newslist">{{item}}</view>
<!--3使用組件 -->
<uni-load-more  :loadingType="loadingType" :contentText="contentText" ></uni-load-more>
</view>
</template>

<script>
//1引入組件 uni-load-more.vue
import uniLoadMore from '../../component/uni-load-more.vue';

var _self,
page = 1,
timer = null;
// 定義全局參數(shù),控制數(shù)據(jù)加載

export default {
    components: {//2注冊(cè)組件
        uniLoadMore
    },
    data: {
        newsList: [],
        loadingText: '加載中...',
        loadingType: 0,//定義加載方式 0---contentdown  1---contentrefresh 2---contentnomore
        contentText: {
            contentdown:'上拉顯示更多',
            contentrefresh: '正在加載...',
            contentnomore: '沒有更多數(shù)據(jù)了'
        }
    },
    onLoad: function() {
        _self = this;
//頁面一加載時(shí)請(qǐng)求一次數(shù)據(jù)
        this.getnewsList();
    },
    onPullDownRefresh: function() {
//下拉刷新的時(shí)候請(qǐng)求一次數(shù)據(jù)
        this.getnewsList();
    },
    onReachBottom: function() {
//觸底的時(shí)候請(qǐng)求數(shù)據(jù),即為上拉加載更多
//為了更加清楚的看到效果,添加了定時(shí)器
        if (timer != null) {
            clearTimeout(timer);
        }
        timer = setTimeout(function() {
            _self.getmorenews();
        }, 1000);

// 正常應(yīng)為:
// _self.getmorenews();
    },
    methods: {
        getmorenews: function() {
            if (_self.loadingType !== 0) {//loadingType!=0;直接返回
                return false;
            }
            _self.loadingType = 1;
            uni.showNavigationBarLoading();//顯示加載動(dòng)畫
            uni.request({
                url:'https://demo.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=list1&page=' + page,
                method: 'GET',
                success: function(res) {
                    console.log(JSON.stringify(res));
                    if (res.data == null) {//沒有數(shù)據(jù)
                        _self.loadingType = 2;
                        uni.hideNavigationBarLoading();//關(guān)閉加載動(dòng)畫
                        return;
                    }
                    page++;//每觸底一次 page +1
                    _self.newsList = _self.newsList.concat(res.data.split('--hcSplitor--'));//將數(shù)據(jù)拼接在一起
                    _self.loadingType = 0;//將loadingType歸0重置
                    uni.hideNavigationBarLoading();//關(guān)閉加載動(dòng)畫
                }
            });
        },
        getnewsList: function() {//第一次回去數(shù)據(jù)
            page = 1;
            this.loadingType = 0;
            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++;//得到數(shù)據(jù)之后page+1
                    _self.newsList = res.data.split('--hcSplitor--');
                    uni.hideNavigationBarLoading();
                    uni.stopPullDownRefresh();//得到數(shù)據(jù)后停止下拉刷新
                }
            });
        }
    }
};
</script>
<style>
.newslist{padding:10px;line-height:60px;font-size:28px;}
.loading{text-align:center;line-height:80px;}
</style>


直接復(fù)制過去就能調(diào)用了,趕快試試吧

來源地址:https://blog.csdn.net/qq_39197547/article/details/84832913

后一頁:沒有了
相關(guān)閱讀
深山行者留言系統(tǒng)V1.0 (簡(jiǎn)稱深山留言V1.0)
自適應(yīng)高度textarea(文本框)
經(jīng)典表格隔行變色程序
鄧州市途鴻旅行社
輸入框提示列表效果
正則的常表達(dá)式
126郵箱TAB效果(同一頁面可多次使用)
ASP事務(wù)處理 for access
共有0條關(guān)于《uni-app實(shí)現(xiàn)上拉加載,下拉刷新(下拉帶動(dòng)畫)》的評(píng)論
發(fā)表評(píng)論
正在加載評(píng)論......
返回頂部發(fā)表評(píng)論
呢 稱:
表 情:
內(nèi) 容:
評(píng)論內(nèi)容:不能超過 1000 字,需審核,請(qǐng)自覺遵守互聯(lián)網(wǎng)相關(guān)政策法規(guī)。
驗(yàn)證碼: 驗(yàn)證碼 
網(wǎng)友評(píng)論聲明,請(qǐng)自覺遵守互聯(lián)網(wǎng)相關(guān)政策法規(guī)。

您發(fā)布的評(píng)論即表示同意遵守以下條款:
一、不得利用本站危害國(guó)家安全、泄露國(guó)家秘密,不得侵犯國(guó)家、社會(huì)、集體和公民的合法權(quán)益;
二、不得發(fā)布國(guó)家法律、法規(guī)明令禁止的內(nèi)容;互相尊重,對(duì)自己在本站的言論和行為負(fù)責(zé);
三、本站對(duì)您所發(fā)布內(nèi)容擁有處置權(quán)。

更多信息>>欄目類別選擇
百度小程序開發(fā)
微信小程序開發(fā)
微信公眾號(hào)開發(fā)
uni-app
asp函數(shù)庫
ASP
DIV+CSS
HTML
python
更多>>同類信息
uni-app開發(fā)表單input組件的一些規(guī)則說明自己預(yù)留使用
uni-app:使用uni.downloadFile下載word或pdf文件并保存到手機(jī)
小程序中利用addPhoneContact將聯(lián)系人的信息添加到手機(jī)通訊錄支持保存聯(lián)系人頭像
微信小程序打開客服提示:該小程序提供的服務(wù)出現(xiàn)故障,請(qǐng)稍后重試
微信小程序客服會(huì)話只能過button讓用戶主動(dòng)觸發(fā)
uni-app開發(fā)微信小程序使用button的open-type為contact調(diào)用微信客服不能用view或者js調(diào)用
更多>>最新添加文章
dw里面查找替換使用正則刪除sqlserver里面的CONSTRAINT
Android移動(dòng)端自動(dòng)化測(cè)試:使用UIAutomatorViewer與Selenium定位元素
抖音直播音掛載小雪花 懂車帝小程序
javascript獲取瀏覽器指紋可以用來做投票
火狐Mozilla Firefox出現(xiàn):無法載入您的Firefox配置文件 它可能已經(jīng)丟失 或是無法訪問 問題解決集合處理辦法
在Android、iOS、Windows、MacOS中微信小程序的文件存放路徑
python通過代碼修改pip下載源讓下載庫飛起
python里面requests.post返回的res.text還有其它的嗎
更多>>隨機(jī)抽取信息
asp讀取163的rss之xml數(shù)據(jù)
鄧州市途鴻旅行社
愛尚學(xué)生網(wǎng)
獲取客戶真實(shí)IP地址
頁面里面的js和css的放的位置順序與加載速度分析
asp無限級(jí)調(diào)用分類顯示
主站蜘蛛池模板: 日本精品久久久一区二区三区 | 精品国产第一国产综合精品 | 一二三四在线视频观看社区 | 亚洲大片免费观看 | 中文字幕av在线 | 在线激情视频 | 欧美日韩高清一区 | 一区日韩| 中文字幕在线看第二 | 成人免费在线观看视频 | 国产一区在线看 | 久久精视频 | 欧美一区精品 | 日本免费在线视频 | 69日影院 | 日韩中文字幕在线免费 | 国产精品欧美一区二区三区 | 狠狠综合久久av一区二区老牛 | 国产一级影片 | 欧美成人一区二区 | 黄色大片网 | 黄色地址 | 久久三区 | 亚洲精品乱码久久久久久蜜桃 | 久草天堂| 午夜视频网 | 国偷自产av一区二区三区 | 国产成人精品av | 国产一级在线观看 | 欧美综合一区二区三区 | 日p视频免费看 | 国产一区91 | av免费看在线 | 久久久久一区二区三区 | 男人天堂av网 | aa毛片| 天天精品| 国产精品久久在线观看 | 私人毛片免费高清视频 | 亚洲欧美视频在线 | 日韩欧美国产成人一区二区 |