技术标签: 下拉刷新 vue uni-app uni-app上拉加载跟多
直接代码展示了
uni-app的上拉加载动画感觉还行,废话不多说了。。。
1在pages.json添加允许下拉刷新
{
"path":"pages/lookuser/lookuser",
"style":{
"navigationBarTitleText":"用户日志",
"enablePullDownRefresh": true//就是这个
}
}
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: {
//上拉的状态: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: "没有更多数据了"
};
}
}
},
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.在页面上调用组件
<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;
// 定义全局参数,控制数据加载
export default {
components: {//2注册组件
uniLoadMore
},
data: {
newsList: [],
loadingText: '加载中...',
loadingType: 0,//定义加载方式 0---contentdown 1---contentrefresh 2---contentnomore
contentText: {
contentdown:'上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
}
},
onLoad: function() {
_self = this;
//页面一加载时请求一次数据
this.getnewsList();
},
onPullDownRefresh: function() {
//下拉刷新的时候请求一次数据
this.getnewsList();
},
onReachBottom: function() {
//触底的时候请求数据,即为上拉加载更多
//为了更加清楚的看到效果,添加了定时器
if (timer != null) {
clearTimeout(timer);
}
timer = setTimeout(function() {
_self.getmorenews();
}, 1000);
// 正常应为:
// _self.getmorenews();
},
methods: {
getmorenews: function() {
if (_self.loadingType !== 0) {//loadingType!=0;直接返回
return false;
}
_self.loadingType = 1;
uni.showNavigationBarLoading();//显示加载动画
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) {//没有数据
_self.loadingType = 2;
uni.hideNavigationBarLoading();//关闭加载动画
return;
}
page++;//每触底一次 page +1
_self.newsList = _self.newsList.concat(res.data.split('--hcSplitor--'));//将数据拼接在一起
_self.loadingType = 0;//将loadingType归0重置
uni.hideNavigationBarLoading();//关闭加载动画
}
});
},
getnewsList: function() {//第一次回去数据
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++;//得到数据之后page+1
_self.newsList = res.data.split('--hcSplitor--');
uni.hideNavigationBarLoading();
uni.stopPullDownRefresh();//得到数据后停止下拉刷新
}
});
}
}
};
</script>
<style>
.newslist {
padding: 10px;
line-height: 60px;
font-size: 28px;
}
.loading {
text-align: center;
line-height: 80px;
}
</style>
具体说明代码里面已经注释好了
现在将代码复制过去就能调用了,赶快试试吧
文章浏览阅读699次,点赞2次,收藏3次。windows11下配置visual studio 2022 nginx工程_nginx visual studio
文章浏览阅读483次。自定义emacs配置,可以进行一步到位的配置工作_emacs设置
文章浏览阅读3.2k次。@本文来源于公众号:csdn2299,喜欢可以关注公众号 程序员学府这篇文章主要介绍了python 动态库m.so.1.0错误问题,文中给大家提到了python中使用动态库的方法,通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下$ python -V python: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No _libpython3.9m.so.1.0
文章浏览阅读4k次,点赞19次,收藏23次。Apriori 算法是一种用于关联规则挖掘的经典算法。它用于在大规模数据集中发现频繁项集,进而生成关联规则。关联规则揭示了数据集中项之间的关联关系,常被用于市场篮分析、推荐系统等应用。Apriori 算法的主要优点是它相对简单,并且易于理解和实现。然而,在处理大规模数据集时,它可能面临性能挑战。后续的改进算法,如 FP-Growth 等,通过不同的方式优化了频繁项集的发现过程,提高了算法的效率。_apriori算法
文章浏览阅读1.2k次,点赞17次,收藏12次。基于R语言lavaan程序包,通过理论讲解和实际操作相结合的方式,由浅入深地系统介绍结构方程模型的建立、拟合、评估、筛选和结果展示的全过程。我们筛选大量经典案例
文章浏览阅读9.2k次。一、焊工考试多少分及格?焊工特种作业操作证考试80分就算及格,特种作业操作证考试分理论和实际操作证两项考试;理论是微机考试,从题库自动抽取题目。实际操作证考试包括模拟操作、口试等。焊工职业资格证书考试理论与实操各60分为及格分。二、答题技巧首先,在理论考试的时候一定要谨记以安全为主,任何不安全的行为都是不符合逻辑以及常理的,一定是不正确的答案。其次,实际操作一定要注重细节。实际操作中往往就是细节的地方需要注意,大部分的考试可能都是要以口述为主,所以细节的地方一定要主要记..._焊工考试多少分及格
文章浏览阅读1.2k次。当我们的Jenkins要在某一台固定的电脑执行,我们则要将这台电脑加到Jenkins里。操作步骤如下:1、节点管理点击Jenkins首页,然后点击系统管理–节点管理,进入到节点管理页面2、点击新建节点3、在执行(测试)机器上,我们可以同时执行几个任务。远程工作目录:即我们放置代码的目录,我们要执行的代码的目录![在这里插入图片描述](https://img-blog.csdnimg.cn/20200618192134332.pngUsage:(1)尽可能的使用这个节点:即既可以_windows jenkins调用git bash
文章浏览阅读4.1k次,点赞2次,收藏17次。Introduction to Freesurfer Outputhttps://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/OutputData_freeviewhttps://blog.csdn.net/qq_28480795/article/details/105094883本教程旨在介绍Freeview。有关此处未介绍的按钮或菜单选项的信息,您可以在FreeviewGuide wiki上找到。主要内容:如何可视化和检查FreeSurfer数据_brodmann and exvio ec labels
文章浏览阅读263次,点赞3次,收藏4次。近年来,随着微信的快速发展,基于微信平台的应用层出不穷,许多商家也将点餐系统部署到了微信平台上,顾客可以从微信直接登录到点餐系统中进行菜品浏览,下单与支付,这使得点餐变得更加方便与快捷。本课题针对奶茶店设计出一个奶茶点餐微信小程序,奶茶点餐小程序可以帮助传统实体奶茶店在线上实现奶茶的售卖,并且使顾客也能更加方便快捷地购买到自己想要的奶茶饮品。博主介绍:全网粉丝10W+,CSDN全栈领域优质创作者,博客之星、掘金/华为云/阿里云等平台优质作者。 精彩专栏 推荐订阅。
文章浏览阅读4.3k次。概念:μVision:是Keil的文本编辑界面。目前的μVision支持代码自动补全。如果想使用外部的文本编辑器,可以在Tools-Customize Tools Menu设置。MDK:就是Keil for ARM。全称Microcontroller Development Kit。具体可以参考这里的说明。调试方法:调试方法分两种:软件仿真和硬件调试,即Simulator和Debugger。_keil for arm mdk
文章浏览阅读3.3k次。mpeg4 码流格式及判断关键帧_mpeg4 关键帧
文章浏览阅读410次。单身和已婚不能同时选中,不了解保险和已了解保险不能同时选中。同时各个标签点击可以取消选择//html与我相关v-for="(item, index) in myself":key="index"@click="checkButton('myself', item.id)":class="item.isFlag ? 'current' : ''">{{item.title}}标签v-for="..._jsp span不支持选中