当前位置:网站首页>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>
边栏推荐
- Impact relay jc-7/11/dc110v
- SQL injection - injection based on MSSQL (SQL Server)
- C language exercises (recursion)
- ES6 模块化
- 509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
- Canoe panel learning video
- px em rem的区别
- FRP intranet penetration, reverse proxy
- [Excel] 数据透视图
- webrtc 快速搭建 视频通话 视频会议
猜你喜欢
BUU-Crypto-[HDCTF2019]basic rsa
Accidentally deleted the data file of Clickhouse, can it be restored?
A little understanding of GSLB (global server load balance) technology
Design and implementation of redis 7.0 multi part AOF
buuctf-pwn write-ups (8)
ansys命令
JSON Web Token----JWT和傳統session登錄認證對比
Actual cases and optimization solutions of cloud native architecture
Impact relay jc-7/11/dc110v
Input displays the currently selected picture
随机推荐
fastjson
Nexus 6p downgraded from 8.0 to 6.0+root
fastjson
BUU-Crypto-[HDCTF2019]basic rsa
JS arguments parameter usage and explanation
Introduction to AMBA
One click filtering to select Baidu online disk files
Take you to quickly learn how to use qsort and simulate qsort
left_ and_ right_ Net interpretable design
Canoe panel learning video
js如何将秒转换成时分秒显示
BUU-Crypto-[GUET-CTF2019]BabyRSA
win10清除快速访问-不留下痕迹
Nexus 6p从8.0降级6.0+root
JS get the attribute values nested in the object
Component、Container容器常用API详解:Frame、Panel、ScrollPane
QT releases multilingual International Translation
检漏继电器JY82-2P
How to solve the component conflicts caused by scrollbars in GridView
安装 Pytorch geometric