当前位置:网站首页>Drop down refresh and pull-up load of product list of uni app project
Drop down refresh and pull-up load of product list of uni app project
2022-04-22 09:45:00 【Xiao Zheliang】
Catalog
uni-app Project Drop down refresh of product list And Pull up to load more
uni-app Project A list of goods Pull up to load more
goods.vue
<template>
<view class="goods_wrap">
<view class="goods_list">
<view class="goods_list_item" v-for="item in shopList">
{
{
item.title}}
</view>
</view>
<view class="isOver" v-if="isOverFlag">
---- I have a bottom line ----
</view>
</view>
</template>
<script>
export default {
data() {
return {
shopList:[],
pageIndex:1,
isOverFlag:false,
}
},
onLoad() {
this.getShopList();
},
// Touch the bottom to trigger
onReachBottom() {
console.log(" Touch the bottom to trigger ", this.shopList.length);
// First judge whether there is data on the next page
if ( this.shopList.length < this.pageIndex * 10) return this.isOverFlag = true;
this.pageIndex++
this.getShopList();
},
methods: {
// Get a list of products
async getShopList(){
const res = await this.$myHttp({
url:"/shopList?pageIndex=" + this.pageIndex,
})
// Get product data
this.shopList = [...this.shopList,...res.data];
},
}
}
</script>
<style lang="scss">
.goods_wrap{
height: 100%;
width: 100%;
background: pink;
.goods_list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 15rpx;
.goods_list_item {
box-sizing: border-box;
margin-bottom: 15rpx;
background: #fff;
width: 355rpx;
height: 400rpx;
line-height: 400rpx;
text-align: center;
}
}
.isOver {
width: 100%;
text-align: center;
}
}
</style>
effect

uni-app Project Drop down refresh of product list
goods.vue
<template>
<view class="goods_wrap">
<view class="goods_list">
<view class="goods_list_item" v-for="item in shopList">
{
{
item.title}}
</view>
</view>
<view class="isOver" v-if="isOverFlag">
---- I have a bottom line ----
</view>
</view>
</template>
<script>
export default {
data() {
return {
shopList:[],
pageIndex:1,
isOverFlag:false,
}
},
onLoad() {
this.getShopList();
},
// Touch the bottom to trigger
onReachBottom() {
console.log(" Touch the bottom to trigger ", this.shopList.length);
// First judge whether there is data on the next page
if ( this.shopList.length < this.pageIndex * 10) return this.isOverFlag = true;
this.pageIndex++
this.getShopList();
},
// Pull down refresh
onPullDownRefresh(){
console.log(" Pull down refresh ");
this.pageIndex = 1;
this.shopList = [];
this.isOverFlag = false;
setTimeout(()=> {
this.getShopList(()=>{
uni.stopPullDownRefresh(); // Turn off pull-down refresh
});
}, 1000 )
},
methods: {
// Get a list of products
async getShopList(callBack){
const res = await this.$myHttp({
url:"/shopList?pageIndex=" + this.pageIndex,
})
// Get product data
this.shopList = [...this.shopList,...res.data];
callBack && callBack()
},
}
}
</script>
<style lang="scss">
.goods_wrap{
height: 100%;
width: 100%;
background: pink;
.goods_list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 15rpx;
.goods_list_item {
box-sizing: border-box;
margin-bottom: 15rpx;
background: #fff;
width: 355rpx;
height: 400rpx;
line-height: 400rpx;
text-align: center;
}
}
.isOver {
width: 100%;
text-align: center;
}
}
</style>
pages.json
- “enablePullDownRefresh”:true//
{
"pages": [ //pages The first item in the array represents the application startup page , Reference resources :https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index"
}
,{
"path" : "pages/cart/cart"
}
,{
"path" : "pages/member/member"
}
,{
"path" : "pages/news/news"
}
,{
"path" : "pages/goods/goods",
"style": {
"enablePullDownRefresh":true// Turn on pull-down refresh
}
}
,{
"path" : "pages/contact/contact"
}
,{
"path" : "pages/pics/pics"
}
,{
"path" : "pages/learn/learn"
}
],
"globalStyle": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": "xzl- The mall ",
"navigationBarBackgroundColor": "#b50e03",
"backgroundColor": "#F8F8F8"
},
"tabBar":{
"selectedColor":"#b50e03",
"list":[
{
"text":" home page ",
"pagePath":"pages/index/index",
"iconPath":"static/icon/home.png",
"selectedIconPath":"static/icon/home-active.png"
},
{
"text":" Journalism ",
"pagePath":"pages/news/news",
"iconPath":"static/icon/news.png",
"selectedIconPath":"static/icon/news-active.png"
},
{
"text":" The shopping cart ",
"pagePath":"pages/cart/cart",
"iconPath":"./static/icon/cart.png",
"selectedIconPath":"static/icon/cart-active.png"
},
{
"text":" members ",
"pagePath":"pages/member/member",
"iconPath":"static/icon/member.png",
"selectedIconPath":"static/icon/member-active.png"
}
]
}
}
effect
- Pull up

版权声明
本文为[Xiao Zheliang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220924522536.html
边栏推荐
- etcd 中watchableStore 存储的实现解析
- 杰理之复位IO维持电平使用说明【篇】
- L3-005 dustbin distribution (30 points) (dijkstar)
- 【有趣的编程题之适龄的朋友】(Leetcode原题详解)
- The web application scans the code to obtain the user information of zhezheng nail
- SQL 表达式
- Kernel pwn 基础教程之 Heap Overflow
- L3-003 social cluster (30 points) (concurrent search)
- Qtabelwidget instance
- Easy to use screenshot software
猜你喜欢

三极管、场效应管和MOS管三者的工作原理

VLAN——虚拟局域网概述

超越 iTerm!号称下一代 Terminal 终端神器,用完爱不释手!

QT布局管理复习

Beyond iterm! Known as the next generation terminal artifact, I can't put it down after using it!

基于Transform的深度学习目标检测(DETR模型)

二极管工作原理

Aardio - 【库】webp图片转换

source_ Insight is a method to create a new project and search for a variable or function in the whole document

MOS管及MOS管驱动电路案例分析-KIA MOS管
随机推荐
浅析MOS管开关速度影响因素-KIA MOS管
[age appropriate friends of interesting programming questions] (detailed explanation of the original title of leetcode)
遥感图像分割数据集整理(发布)
Cloud native enthusiast weekly: looking for open source alternatives to netlify
L3-002 特殊堆栈 (30 分) (二分 栈
etcd 如何实现同步监听
经典场效应管如何快速关断技巧-KIA MOS管
基于MOSFET控制的大范围连续可调(0~45V) 的小功率稳压电源设计实例
2022-04-21 mysql-innodb存储引擎核心处理
QT AxObject库的简单操作
Aardio - 【库】webp图片转换
Sorting and publishing of remote sensing image segmentation data set
SQL 创建数据库
Biden announced another $800 million in security assistance to Ukraine
stringstream的用法
L3-007 ladder map (30 points) (condition DIJ)
杰理之通常影响CPU性能测试结果的因素有:【篇】
L2-033 简单计算器 (25 分)
SQL expression
[SQL Server] SQL overview