当前位置:网站首页>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>
边栏推荐
- AWT introduction
- [excel] PivotChart
- Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
- Tutle clock improved version
- Arc135 C (the proof is not very clear)
- 报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
- 70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
- 体验碎周报第 102 期(2022.7.4)
- C language exercises (recursion)
- LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
猜你喜欢
AWT介绍
The end of the Internet is rural revitalization
BUU-Pwn-test_ your_ nc
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
webrtc 快速搭建 视频通话 视频会议
BUU-Crypto-[GXYCTF2019]CheckIn
【无标题】
Google Chrome browser will support the function of selecting text translation
Leetcode question brushing record | 206_ Reverse linked list
Take you to quickly learn how to use qsort and simulate qsort
随机推荐
ES6 模块化
[excel] PivotChart
Design and implementation of redis 7.0 multi part AOF
js获取对象中嵌套的属性值
Compound nonlinear feedback control (2)
The difference between PX EM rem
What are the reasons for the frequent high CPU of ECS?
Practical gadget instructions
High performance parallel programming and optimization | lesson 02 homework at home
Arc135 C (the proof is not very clear)
A little understanding of GSLB (global server load balance) technology
Nexus 6p从8.0降级6.0+root
JS arguments parameter usage and explanation
Steady! Huawei micro certification Huawei cloud computing service practice is stable!
Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
724. Find the central subscript of the array
lightroom 导入图片灰色/黑色矩形 多显示器
Qt发布多语言国际化翻译
如何避免 JVM 内存泄漏?
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane