FetchTable.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar>
  5. <a-button type="primary" @click="handleReloadCurrent"> 刷新当前页 </a-button>
  6. <a-button type="primary" @click="handleReload"> 刷新并返回第一页 </a-button>
  7. </template>
  8. </BasicTable>
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import { defineComponent } from 'vue';
  13. import { BasicTable, useTable } from '/@/components/Table';
  14. import { getBasicColumns } from './tableData';
  15. import { demoListApi } from '/@/api/demo/table';
  16. export default defineComponent({
  17. components: { BasicTable },
  18. setup() {
  19. const [registerTable, { reload }] = useTable({
  20. title: '远程加载示例',
  21. api: demoListApi,
  22. columns: getBasicColumns(),
  23. });
  24. function handleReloadCurrent() {
  25. reload();
  26. }
  27. function handleReload() {
  28. reload({
  29. page: 1,
  30. });
  31. }
  32. return {
  33. registerTable,
  34. handleReloadCurrent,
  35. handleReload,
  36. };
  37. },
  38. });
  39. </script>