当前位置:网站首页>Scroll view pull-down refresh and pull-up load (bottom)
Scroll view pull-down refresh and pull-up load (bottom)
2022-07-26 04:19:00 【richest_ qi】
List of articles
Antecedents feed
Components :scroll-view
scroll-view It can realize a scrollable view area .
scroll-view Components have many properties , Commonly used :
enable-flex, Is it enabled? flex Layout , Only enable ,display:flexWill take effect . Boolean value , The default isfalse, That is, it is not enabled by default flex Layout .scroll-x, Whether horizontal scrolling is allowed . Boolean value , The default isfalse, That is, horizontal scrolling is not allowed by default .scroll-y, Allow vertical scrolling . Boolean value , The default isfalse, That is, vertical scrolling is not allowed by default . When using vertical scrolling , Need to give scroll-view Set a fixed height , That is, through wxss Set up height, The unit is rpx or px.scroll-into-view, Automatically scroll to the position of the specified element . Its value isscroll-viewOf the subelements ofid,idIs a string type , And can't start with a number .scroll-with-animation, Whether to use animation transition when scrolling the scroll bar . Boolean value , The default value isfalse, That is, animation transition is not used by default when scrolling .refresher-enabled, Enable pull-down refresh , Boolean value , The default isfalse, That is, pull-down refresh is not enabled by default .refresher-triggered, Set the current pull-down refresh status ,trueIndicates that the pull-down refresh has been triggered ,falseIndicates that the pull-down refresh is not triggered .bindrefresherrefresh, Triggered on pull-down refresh . Only when the pull-down refresh is enabled can it take effect , namelyrefresher-enabledIt has to be fortruewhen .bindscrolltolower, Scroll to the bottom ( Or on the right ) Trigger when .
Applet project
The main files involved in the code are :
- app.json
- pages/index/index.wxml
- pages/index/index.wxss
- pages/index/index.js

app.json
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarBackgroundColor": "#0149af",
"navigationBarTitleText": " home page ",
"navigationBarTextStyle": "white"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
pages/index/index.wxml
<view class="cameraContainer">
<view class="header">
<input type="text" class="search" placeholder=" Search for There's everything here "/>
<image src="/static/images/search.png"></image>
</view>
<view class="tabContainer">
<scroll-view class="tabs" enable-flex scroll-x scroll-into-view="{
{tabId}}" scroll-with-animation>
<view class="tab {
{item.id===tabId?'active':''}}" wx:for="{
{tabList}}" wx:key="id" id="{
{item.id}}" bindtap="changeTab">
{
{item.name}}
</view>
</scroll-view>
</view>
<scroll-view class="contentContainer" scroll-y refresher-enabled refresher-triggered="{
{isTriggered}}" bindrefresherrefresh="handleRefresherRefresh" bindscrolltolower="handleScrollToLower" >
<view class="content" wx:for="{
{contentList}}" wx:key="{
{index}}">{
{item}}</view>
</scroll-view>
</view>
pages/index/index.wxss
.cameraContainer{
padding: 10rpx;
}
.header{
display: flex;
align-items: center;
border: 1rpx solid #aaa;
border-radius: 6rpx;
padding: 6rpx 10rpx;
}
.header image{
width: 36rpx;
height: 36rpx;
padding: 0 10rpx;
}
.header .search{
flex: 1;
height: 36rpx;
line-height: 36rpx;
font-size: 26rpx;
}
.tabContainer{
margin-top: 20rpx;
}
.tabs{
display: flex;
height: 50rpx;
}
.tab{
height: 40rpx;
line-height: 40rpx;
margin-right: 30rpx;
white-space: nowrap;
font-size: 28rpx;
}
.active{
border-bottom: 4rpx solid #1a74f1;
}
.contentContainer{
height: calc(100vh - 150rpx);
}
.content{
width: 100%;
height: 600rpx;
line-height: 600rpx;
text-align: center;
background:#eee;
color: #1a74f1;
font-size: 64rpx;
border-radius: 10rpx;
margin-bottom: 10rpx;
}
pages/index/index.js
Page({
data:{
tabList:[],
tabId:'',
contentList:[],
isTriggered:false
},
onLoad(){
this.getTabList();
},
changeTab(e){
const tabId = e.target.id;
const contentList = this.getContentList(tabId);
this.setData({
contentList,tabId})
},
getTabList(){
let result = [
{
"id": "tab_1","name": " food "},
{
"id": "tab_2","name": " Bodybuilding "},
{
"id": "tab_3","name": " The movie "},
{
"id": "tab_4","name": " The hotel "},
{
"id": "tab_5","name": " Scenic spot "},
{
"id": "tab_6","name": " The supermarket ",},
{
"id": "tab_7","name": " Fruits "},
{
"id": "tab_8","name": " fresh "},
{
"id": "tab_9","name": " Tobacco and alcohol "},
{
"id": "tab_10","name": " Buy medicine ",},
{
"id": "tab_11","name": " train "},
{
"id": "tab_12","name": " subsidy "},
{
"id": "tab_13","name": " Home Furnishing "},
{
"id": "tab_14","name": " Pets "},
{
"id": "tab_15","name": " game "}
]
this.setData({
tabList:result,
tabId:result[0].id,
contentList:this.getContentList(result[0].id)
})
},
getContentList(tabId=""){
let result = [" other "," other "," other "," other "," other "];
if(tabId.indexOf("1") > -1){
result = [" KFC house express "," Sea of clouds food "," Xibei youmian village "," East slope of Meizhou "," Wallace "];
}else if (tabId.indexOf("2") > -1){
result = [" swimming "," Martial arts fight "," yoga "," badminton "," Basketball "];
}else if(tabId.indexOf("3") > -1){
result = [" Young Babylon "," forever "," Love myth "," Iron man "," Kung Fu Panda "]
}
this.setData({
isTriggered:false})
return result;
},
handleRefresherRefresh(){
console.log("handle refresher refresh")
this.getContentList(this.data.tabId)
},
handleScrollToLower(){
console.log("handle scroll to lower");
const temp = this.getContentList()
const newContentList = [...this.data.contentList,...temp];
this.setData({
contentList:newContentList})
}
})
Related links
- Use scroll-view Realize vertical scrolling of content list
- Use scroll-view Realization tabs( Increase animation transition effect )
- Use scroll-view Realization tabs
- Implementation of slider view
- Use scroll-view Possible problems and solutions in implementing slider view
- Wechat applet to event Object passing data
- flex Layout :flex-basic flex-grow flex-basis
边栏推荐
- `Oi problem solving ` ` leetcode '2040. The k-th minor product of two ordered arrays
- Tutorial on using the one click upgrade function of the rtsp/onvif protocol video platform easynvr service
- Linear basis property function code to achieve 3000 words detailed explanation, with examples
- Under the high debt of Red Star Macalline, is it eyeing new energy?
- Segger embedded studio cannot find xxx.c or xxx.h file
- Apisex's exploration in the field of API and microservices
- [question 019: what is the understanding of spherecastcommand in unity?]
- Day26 job
- Yadi started to slow down after high-end
- Sangi diagram of machine learning (for user behavior analysis)
猜你喜欢

吴恩达机器学习课后习题——线性回归

When you try to delete all bad code in the program | daily anecdotes

Acwing_ 12. Find a specific solution for the knapsack problem_ dp

Firewall command simple operation

Li Kou daily question - day 42 -661. Picture smoother

Go plus security: an indispensable security ecological infrastructure for build Web3

文献|关系研究能得出因果性结论吗

This article takes you to graph transformers

Go Plus Security:一款Build Web3不可或缺的安全生态基础设施

What are the duplicate check rules for English papers?
随机推荐
Firewall command simple operation
工程师如何对待开源 --- 一个老工程师的肺腑之言
生活相关——十年的职业历程(转)
1. Mx6u system migration-6-uboot graphical configuration
2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
Sangi diagram of machine learning (for user behavior analysis)
Implementation of distributed lock
Working ideas of stability and high availability guarantee
Yadi started to slow down after high-end
Luoda Development -- the context of sidetone configuration
Helloworld案例分析
Getting started with mongodb Basics
Acwing_ 12. Find a specific solution for the knapsack problem_ dp
Pathmatchingresourcepatternresolver parsing configuration file resource file
makefile知识再整理(超详细)
吴恩达机器学习课后习题——线性回归
Segger embedded studio cannot find xxx.c or xxx.h file
[oi knowledge] dichotomy, dichotomy concept, integer dichotomy, floating point dichotomy
Lua and go mixed call debugging records support cross platform (implemented through C and luajit)
Retail chain store cashier system source code management commodity classification function logic sharing