当前位置:   article > 正文

Naive UI之BasicTable 序号 和 render

basictable 序号

 columns:(表格项)

  1. import { NText } from 'naive-ui';
  2. import { h } from 'vue';
  3. const statusOptions = {
  4. 1: { text: '种类1', type: '' },
  5. 2: { text: '种类2', type: '' },
  6. };
  7. export const columns = [
  8. { type: 'selection', key: 'selection' },//复选框列
  9. {
  10. title: '序号',
  11. width: 40,
  12. align: 'center',
  13. render: (text: any, record: any, index: any) => {
  14. return record + 1;
  15. },
  16. },
  17. {
  18. title: '标题',
  19. key: 'content',
  20. width: 100,
  21. align: 'center',
  22. },
  23. {
  24. title: '类型',
  25. key: 'type',
  26. width: 100,
  27. align: 'center',
  28. render(row) {
  29. return h(
  30. NText,
  31. {
  32. type: statusOptions[row.type].type,
  33. },
  34. { default: () => statusOptions[row.type].text }
  35. );
  36. },
  37. },
  38. ];

request请求

  1. const loadDataTable = async (res) => {
  2. tableData.value = await getList({ ...params.value, ...res });
  3. return tableData.value;
  4. };

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号