当前位置:网站首页>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>边栏推荐
- Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
- What are the reasons for the frequent high CPU of ECS?
- win10清除快速访问-不留下痕迹
- js如何将秒转换成时分秒显示
- Uninstall Google drive hard drive - you must exit the program to uninstall
- The difference between PX EM rem
- Take you to quickly learn how to use qsort and simulate qsort
- JS flattened array of number shape structure
- ES6 模块化
- AWT common components, FileDialog file selection box
猜你喜欢

JSON Web Token----JWT和传统session登录认证对比

BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述

BUU-Pwn-test_ your_ nc

ANSYS command

Gridview出现滚动条,组件冲突,如何解决

ansys命令

C language exercises (recursion)

报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。

Kubernets first meeting

Halcon图片标定,使得后续图片处理过后变成与模板图片一样
随机推荐
el-select如何实现懒加载(带搜索功能)
如何获取el-tree中所有节点的父节点
Tutle clock improved version
The difference between PX EM rem
lightroom 导入图片灰色/黑色矩形 多显示器
Weekly summary (*63): about positive energy
[microservice] Nacos cluster building and loading file configuration
Basic concept of bus
注释与注解
Online shrimp music will be closed in January next year. Netizens call No
每周小结(*63):关于正能量
LC weekly 300
Arc135 C (the proof is not very clear)
[Excel] 数据透视图
Sword finger offer II 038 Daily temperature
Understanding of cross domain and how to solve cross domain problems
One click filtering to select Baidu online disk files
Lightroom import picture gray / Black rectangular multi display
Introduction to AMBA
Programmers don't talk about morality, and use multithreading for Heisi's girlfriend