Files
JayuCloud/FM-Frontend/src/components/admin/AdminMobileCardList.vue
T

39 lines
1.0 KiB
Vue
Raw Normal View History

<template>
<div class="admin-mobile-card-list">
<template v-if="items.length">
<slot
v-for="(item, index) in items"
:key="resolveItemKey(item, index)"
name="item"
:item="item"
:index="index"
/>
</template>
<a-empty v-else :description="emptyDescription" />
</div>
</template>
<script setup lang="ts">
/**
* AdminMobileCardList page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
const props = withDefaults(defineProps<{
items?: any[]
emptyDescription?: string
itemKey?: string
}>(), {
items: () => [],
emptyDescription: '暂无数据',
itemKey: 'id'
})
/** resolveItemKey is a local helper used by this page script. */
const resolveItemKey = (item: Record<string, any> | undefined, index: number) => {
if (item && props.itemKey in item && item[props.itemKey] !== undefined) {
return item[props.itemKey]
}
return index
}
</script>