当前位置:网站首页>Vant --- detailed explanation and use of list component in vant
Vant --- detailed explanation and use of list component in vant
2022-07-04 06:01:00 【Cirrod】
<template>
<van-list
v-model="loading"
:finished="finished"
finished-text=" There is no more "
@load="onLoad"
>
<van-cell v-for="item in list" :key="item.id" :title="item.title" />
</van-list>
</template>
<script>
import { getArticles } from '../../../api/article'
export default {
name: 'ArticleList',
data() {
return {
// Array stored to list data
list: [],
// Control loading loading state
loading: false,
// Control the status of the end of data loading
finished: false,
// Request to get the timestamp of the next page of data
timestamp: null
};
},
mounted() {
},
props: {
channel: {
type: Object,
require: true
}
},
methods: {
// When initializing or scrolling to the bottom, it will trigger the call onload()
async onLoad() {
try {
// 1. Request for data
const { data } = await getArticles({
channel_id: this.channel.id,
timestamp: this.timestamp || Date.now()
})
console.log(data)
// 2. Put the request result in list Array
const { results } = data.data
this.list.push(...results)
// 3. Set the loading status to end after this data loading
this.loading = false
// 4. Determine whether all data is loaded
if (results.length) {
// Update the timestamp to get the data of the next page
this.timestamp = data.data.pre_timestamp
} else {
// There's no data , take finished Set to true, No longer load Load more
this.finished = true
}
} catch (err) {
console.log(' request was aborted !')
}
}
}
}
</script>
<style lang="less" scoped>
</style>边栏推荐
- Component、Container容器常用API详解:Frame、Panel、ScrollPane
- 安装 Pytorch geometric
- Accidentally deleted the data file of Clickhouse, can it be restored?
- Tutle clock improved version
- QT 获取随机颜色值设置label背景色 代码
- How to avoid JVM memory leakage?
- What are the reasons for the frequent high CPU of ECS?
- 接地继电器DD-1/60
- 如何实现视频平台会员多账号登录
- 剑指 Offer II 038. 每日温度
猜你喜欢

transformer坑了多少算力
![Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai](/img/a5/be967170a18cb2de097f01a6d4e039.jpg)
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai

JSON Web Token----JWT和傳統session登錄認證對比

如何展开Collapse 的所有折叠面板

Uninstall Google drive hard drive - you must exit the program to uninstall

Penetration tool - sqlmap

配置交叉编译工具链和环境变量

Kubernets first meeting

1480. Dynamic sum of one-dimensional array

我的NVIDIA开发者之旅——优化显卡性能
随机推荐
Error CVC complex type 2.4. a: Invalid content beginning with element 'base extension' was found. Should start with one of '{layoutlib}'.
配置交叉编译工具链和环境变量
AWT common components, FileDialog file selection box
【无标题】
Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式
"In simple language programming competition (basic)" part 1 Introduction to language Chapter 3 branch structure programming
[Excel] 数据透视图
LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
C语言中的函数(详解)
Canoe panel learning video
Nexus 6p downgraded from 8.0 to 6.0+root
SQL injection - injection based on MSSQL (SQL Server)
Kubernets first meeting
[excel] PivotChart
JSON Web Token----JWT和傳統session登錄認證對比
Thinkphp6.0 middleware with limited access frequency think throttle
JS arguments parameter usage and explanation
Excel comparator
JS get the attribute values nested in the object
Leetcode question brushing record | 206_ Reverse linked list