当前位置:网站首页>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
边栏推荐
- [C language foundation] 13 preprocessor
- I.MX6U-ALPHA开发板(主频和时钟配置实验)
- Small ball and box model, arrangement and combination
- Day24 job
- What model is good for the analysis of influencing factors?
- [project chapter - how to write and map the business model? (3000 word graphic summary suggestions)] project plan of innovation and entrepreneurship competition and application form of national Entrep
- Luoda development - audio stream processing - AAC / loopbacktest as an example
- MATLAB绘图
- Day26 job
- 远坂凛壁纸
猜你喜欢

This article takes you to graph transformers

Makefile knowledge rearrangement (super detailed)

Comprehensive evaluation and decision-making method

Leetcode:1184. Distance between bus stops -- simple

Apisex's exploration in the field of API and microservices

1. Mx6u system migration-6-uboot graphical configuration

p-范数(2-范数 即 欧几里得范数)

吴恩达机器学习课后习题——逻辑回归

2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation

Firewall command simple operation
随机推荐
【SVN】一直出现 Please execute the ‘Cleanup‘ command,cleanup以后没有反应的解决办法
Web测试方法大全
Use of rule engine drools
sorting and searching 二分查找法
Acwing_ 12. Find a specific solution for the knapsack problem_ dp
Huawei issued another global convening order of "genius youth", and some people once gave up their annual salary of 3.6 million to join
2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
How to write the abbreviation of the thesis?
TIA botu WinCC Pro controls the display and hiding of layers through scripts
JS get some attributes of the object
Which websites can I visit to check the latest medical literature?
LeetCode. 6115 count the number of ideal arrays
Maximum average value of continuous interval
吴恩达机器学习课后习题——线性回归
Comprehensive evaluation and decision-making method
【二叉树】二叉树中的最长交错路径
Soft simulation rasterization renderer
Day26 job
What are the differences between vite and wenpack?
Unable to find sygwin.s file during vscode debugging