当前位置:网站首页>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>
边栏推荐
- Excel 比较日器
- 安装 Pytorch geometric
- Lightroom import picture gray / Black rectangular multi display
- Grounding relay dd-1/60
- Use of hutool Pinyin tool
- 接地继电器DD-1/60
- 509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
- How to determine whether an array contains an element
- One click filtering to select Baidu online disk files
- 1.1 history of Statistics
猜你喜欢
724. Find the central subscript of the array
QT 获取随机颜色值设置label背景色 代码
Kubernets first meeting
C language exercises (recursion)
ansys命令
Webrtc quickly set up video call and video conference
QT get random color value and set label background color code
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
C # character similarity comparison general class
随机推荐
QT get random color value and set label background color code
Actual cases and optimization solutions of cloud native architecture
Grounding relay dd-1/60
input显示当前选择的图片
C语言练习题(递归)
left_and_right_net正常版本
LC weekly 300
JSON Web Token----JWT和傳統session登錄認證對比
win10清除快速访问-不留下痕迹
Wechat applet +php realizes authorized login
Upper computer software development - log information is stored in the database based on log4net
每周小结(*63):关于正能量
Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
How to expand all collapse panels
冲击继电器JC-7/11/DC110V
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
安装 Pytorch geometric
SQL injection - injection based on MSSQL (SQL Server)
Risc-v-qemu-virt in FreeRTOS_ Lock mechanism analysis of GCC
如何展开Collapse 的所有折叠面板