-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
230a50a
commit 51c744c
Showing
8 changed files
with
123 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import ComponentButton from './button/index.vue'; | ||
import ComponentCard from './card/index.vue'; | ||
import ComponentTable from './table/index.vue'; | ||
|
||
export { ComponentButton, ComponentCard }; | ||
export { ComponentButton, ComponentCard, ComponentTable }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<template> | ||
<div> | ||
<n-card title="表格" class="h-full shadow-sm rounded-16px"> | ||
<n-space :vertical="true"> | ||
<n-space> | ||
<n-button @click="getDataSource">有数据</n-button> | ||
<n-button @click="getEmptyDataSource">空数据</n-button> | ||
</n-space> | ||
<loading-empty-wrapper class="h-480px" :loading="loading" :empty="empty"> | ||
<n-data-table :columns="columns" :data="dataSource" :flex-height="true" class="h-480px" /> | ||
</loading-empty-wrapper> | ||
</n-space> | ||
</n-card> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, onMounted } from 'vue'; | ||
import { NCard, NSpace, NButton, NDataTable } from 'naive-ui'; | ||
import type { DataTableColumn } from 'naive-ui'; | ||
import { LoadingEmptyWrapper } from '@/components'; | ||
import { useLoadingEmpty } from '@/hooks'; | ||
import { getRandomInterger } from '@/utils'; | ||
interface DataSource { | ||
name: string; | ||
age: number; | ||
address: string; | ||
} | ||
const { loading, startLoading, endLoading, empty, setEmpty } = useLoadingEmpty(); | ||
const columns: DataTableColumn[] = [ | ||
{ | ||
title: 'Name', | ||
key: 'name', | ||
align: 'center' | ||
}, | ||
{ | ||
title: 'Age', | ||
key: 'age' | ||
}, | ||
{ | ||
title: 'Address', | ||
key: 'address' | ||
} | ||
]; | ||
const dataSource = ref<DataSource[]>([]); | ||
function createDataSource(): DataSource[] { | ||
return Array(100) | ||
.fill(1) | ||
.map((item, index) => { | ||
return { | ||
name: `Name${index}`, | ||
age: getRandomInterger(30, 20), | ||
address: '中国' | ||
}; | ||
}); | ||
} | ||
function getDataSource() { | ||
startLoading(); | ||
setTimeout(() => { | ||
dataSource.value = createDataSource(); | ||
endLoading(); | ||
setEmpty(!dataSource.value.length); | ||
}, 1000); | ||
} | ||
function getEmptyDataSource() { | ||
startLoading(); | ||
setTimeout(() => { | ||
dataSource.value = []; | ||
endLoading(); | ||
setEmpty(!dataSource.value.length); | ||
}, 1000); | ||
} | ||
onMounted(() => { | ||
getDataSource(); | ||
}); | ||
</script> | ||
<style scoped></style> |
51c744c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: