index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <PageWrapper title="卡片列表示例" content="基础封装">
  3. <CardList :params="params" :api="demoListApi" @get-method="getMethod" @delete="handleDel">
  4. <template #header>
  5. <Button type="primary" color="error"> 按钮1 </Button>
  6. <Button type="primary" color="success"> 按钮2 </Button>
  7. </template>
  8. </CardList>
  9. </PageWrapper>
  10. </template>
  11. <script lang="ts" setup>
  12. import { CardList } from '/@/components/CardList';
  13. import { Button } from '/@/components/Button';
  14. import { PageWrapper } from '/@/components/Page';
  15. import { demoListApi } from '/@/api/demo/table';
  16. import { useMessage } from '/@/hooks/web/useMessage';
  17. const { notification } = useMessage();
  18. // 请求api时附带参数
  19. const params = {};
  20. let reload = () => {};
  21. // 获取内部fetch方法;
  22. function getMethod(m: any) {
  23. reload = m;
  24. }
  25. //删除按钮事件
  26. function handleDel(id) {
  27. console.log(id);
  28. notification.success({ message: `成功删除${id}` });
  29. reload();
  30. }
  31. </script>