当前位置:网站首页>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>边栏推荐
- Google Chrome browser will support the function of selecting text translation
- Gridview出现滚动条,组件冲突,如何解决
- C语言练习题(递归)
- Use of hutool Pinyin tool
- How to avoid JVM memory leakage?
- [microservice] Nacos cluster building and loading file configuration
- (4) Canal multi instance use
- One click filtering to select Baidu online disk files
- Notes and notes
- 509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
猜你喜欢
![BUU-Crypto-[HDCTF2019]basic rsa](/img/d0/8e451dabb2a6897f6680220d16d04d.jpg)
BUU-Crypto-[HDCTF2019]basic rsa

如何实现视频平台会员多账号登录

LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout

A little understanding of GSLB (global server load balance) technology

QT get random color value and set label background color code

体验碎周报第 102 期(2022.7.4)

Halcon图片标定,使得后续图片处理过后变成与模板图片一样
![[excel] PivotChart](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[excel] PivotChart
![[untitled]](/img/32/cfd45bb5e8555ea2ad344161370dbe.png)
[untitled]

Leetcode question brushing record | 206_ Reverse linked list
随机推荐
QT get random color value and set label background color code
Experience weekly report no. 102 (July 4, 2022)
2022.7.3-----leetcode.556
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
Halcon图片标定,使得后续图片处理过后变成与模板图片一样
gslb(global server load balance)技术的一点理解
Practical gadget instructions
卸载Google Drive 硬盘-必须退出程序才能卸载
transformer坑了多少算力
High performance parallel programming and optimization | lesson 02 homework at home
FRP intranet penetration, reverse proxy
How to determine whether an array contains an element
Arc135 C (the proof is not very clear)
一键过滤选择百度网盘文件
Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
724. Find the central subscript of the array
QT 获取随机颜色值设置label背景色 代码
JS execution mechanism
如何获取el-tree中所有节点的父节点
AWT common components, FileDialog file selection box