Ionic4.x ion-infinite-scroll 上拉分页加载更多
<ion-header>
<ion-toolbar>
<ion-title>
Tab One
</ion-title>
</ion-toolbar>
</ion-header> <ion-content> <ion-list>
<ion-item *ngFor="let item of list">
<ion-label>{{item.title}}</ion-label>
</ion-item>
</ion-list> <ion-infinite-scroll threshold="10%" (ionInfinite)="loadMore($event)">
<ion-infinite-scroll-content loadingSpinner="crescent" loadingText="加载中...">
</ion-infinite-scroll-content>
</ion-infinite-scroll> <p *ngIf="!hasMore">---我是有底线的---</p> </ion-content>
import { Component } from '@angular/core';
import { HttpserviceService } from '../services/httpservice.service';
@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
public list:any[]=[];
public page:any=1;
public hasMore=true;
constructor(public httpService:HttpserviceService){
}
ngOnInit(): void {
this.getData();
}
getData(){
var api='http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page='+this.page;
this.httpService.get(api).then((response:any)=>{
console.log(response)
this.list=response.result;
++this.page;
})
}
loadMore(e){
var api='http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page='+this.page;
this.httpService.get(api).then((response:any)=>{
console.log(response)
this.list=this.list.concat(response.result);
++this.page;
//判断下一页有没有数据
if(response.result.length<20){
e.target.disabled=true;
this.hasMore=false;
}
e.target.complete(); //请求完成数据以后告诉ion-infinite-scroll更新数据
})
}
}
http服务:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class HttpserviceService {
constructor(public http:HttpClient) { }
get(api){
return new Promise((resolve,reject)=>{
this.http.get(api).subscribe((response)=>{
resolve(response);
},(err)=>{
reject(err);
})
})
}
}
Ionic4.x ion-infinite-scroll 上拉分页加载更多的更多相关文章
- 13 Flutter仿京东商城项目 商品列表筛选以及上拉分页加载更多
ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; imp ...
- 12 Flutter仿京东商城项目 商品列表页面请求数据、封装Loading Widget、上拉分页加载更多
ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; imp ...
- ListView下拉刷新,上拉自动加载更多
下拉刷新,Android中非常普遍的功能.为了方便便重写的ListView来实现下拉刷新,同时添加了上拉自动加载更多的功能.设计最初是参考开源中国的Android客户端源码.先看示例图. ...
- Android打造(ListView、GridView等)通用的下拉刷新、上拉自动加载的组件
原文 http://blog.csdn.net/bboyfeiyu/article/details/39253051 前言 下 拉刷新组件在开发中使用率是非常高的,基本上联网的APP都会采 ...
- Android UI--自定义ListView(实现下拉刷新+加载更多)
Android UI--自定义ListView(实现下拉刷新+加载更多) 关于实现ListView下拉刷新和加载更多的实现,我想网上一搜就一堆.不过我就没发现比较实用的,要不就是实现起来太复杂,要不就 ...
- listview下拉刷新 上拉(滑动分页)加载更多
最 近做的类似于微博的项目中,有个Android功能要使用到listview的向下拉刷新来刷新最新消息,向上拉刷新(滑动分页)来加载更多.新浪微博就是使用这种方式的典型.当用户从网络上读取微博的时候, ...
- PullToRefresh下拉刷新 加载更多 详解 +示例
常用设置 项目地址:https://github.com/chrisbanes/Android-PullToRefresh a. 设置刷新模式 如果Mode设置成Mode.PULL_FROM_STAR ...
- Android Demo 下拉刷新+加载更多+滑动删除
小伙伴们在逛淘宝或者是各种app上,都可以看到这样的功能,下拉刷新和加载更多以及滑动删除,刷新,指刷洗之后使之变新,比喻突破旧的而创造出新的,比如在手机上浏览新闻的时候,使用下拉刷新的功能,我们可以第 ...
- ScrollView嵌套ListView嵌套GridView的上下拉以及加载更多
ScrollView 效果 ScrollView 说明 一个ScrollView 嵌套ListView 嵌套GridView的上拉加载更多,下拉刷新的demo. 主要是重写了GridView和Lsit ...
随机推荐
- Java精通并发-notify方法详解及线程获取锁的方式分析
wait(): 在上一次https://www.cnblogs.com/webor2006/p/11404521.html中对于无参数的wait()方法的javadoc进行了解读,而它是调用了一个参数 ...
- 为什么在项目中data需要使用return返回数据呢?
问:为什么在项目中data需要使用return返回数据呢? 答:不使用return包裹的数据会在项目的全局可见,会造成变量污染:使用return包裹后数据中变量只在当前组件中生效,不会影响其他组件.
- Mysql存储引擎中InnoDB与Myisam的区别
1. 事务处理innodb 支持事务功能,myisam 不支持.Myisam 的执行速度更快,性能更好. 2. select ,update ,insert ,delete 操作MyISAM:如果执行 ...
- SSM整合Dubbo登陆案例
登陆案例 一.创建Service项目存放共同数据 1.1 创建实体类 private long id; private String loginName; private String userNa ...
- Xshell5 安装JDK
.执行命令yum -y list java*查看可安装java版本.执行成功后可以看见如下的结果 安装java-1.8全部相关 yum install -y java-1.8.0-openjdk* 使 ...
- BZOJ 4332: JSOI2012 分零食 FFT+分治
好题好题~ #include <bits/stdc++.h> #define N 50020 #define ll long long #define setIO(s) freopen(s ...
- C#实现上传/下载Excel文档
要求 环境信息:WIN2008SERVER 开发工具:VS2015 开发语言:C# 要求: 1.点击同步数据后接口获取数据展示页面同时过滤无效数据并写入数据库,数据可导出Excel并支持分类导出 2 ...
- 《挑战30天C++入门极限》C++类对象的复制-拷贝构造函数
C++类对象的复制-拷贝构造函数 在学习这一章内容前我们已经学习过了类的构造函数和析构函数的相关知识,对于普通类型的对象来说,他们之间的复制是很简单的,例如: int a = 10; int ...
- Python 的特性
Copyright © 1999-2019, CSDN.NET, All Rights Reserved 原 python面试题整理(一) 崔先生的博客阅读数:2402018-08-03 前言 ...
- Linux压缩和解压类指令
一.gzip / gunzip 指令 gzip 用于压缩文件,gunzip 用于解压文件. 基本语法gizp 文件 (功能描述:只能将文件压缩为*.gz文件)gunzip 文件.gz (功能描述 ...