The STable component is a wrapper around the standard Ant Design Vue Table component. It simplifies pagination and data fetching by allowing you to pass a Promise directly to the :data prop. You do not need to manually handle pagination logic in your page component; the component handles it based on the returned Promise.
<template>
<s-table
ref="table"
:columns="columns"
:data="loadData"
/>
</template>
<script>
import STable from '@/components'
export default {
components: { STable },
data() {
return {
columns: [
{ title: 'Name', dataIndex: 'name' }
],
// loadData MUST return a Promise
loadData: parameter => {
return this.$http.get('/api/data', {
params: parameter
}).then(res => {
// The component expects the result structure to contain data, pageNo, and totalCount
return res.result
})
}
}
}
}
</script>