This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
SolarAgent/src/components/posts/PostList.vue
2024-04-02 23:20:21 +08:00

29 lines
910 B
Vue

<template>
<div class="post-list mx-[-8px]">
<v-infinite-scroll :items="props.posts" :onLoad="props.loader">
<template v-for="(item, idx) in props.posts" :key="item.id">
<div class="mb-3 px-[8px]">
<v-card :variant="props.variant ?? 'elevated'">
<template #text>
<post-item brief :item="item" @update:item="(val) => updateItem(idx, val)" />
</template>
</v-card>
</div>
</template>
</v-infinite-scroll>
</div>
</template>
<script setup lang="ts">
import PostItem from "@/components/posts/PostItem.vue"
const props = defineProps<{ variant?: any, posts: any[]; loader: (opts: any) => Promise<any> }>()
const emits = defineEmits(["update:posts"])
function updateItem(idx: number, data: any) {
const posts = JSON.parse(JSON.stringify(props.posts))
posts[idx] = data
emits("update:posts", posts)
}
</script>