Skip to content
On this page

NwTable表格组件

基础用法

简单表格
标题内容数值操作
这是一篇文章0好几份送二代更何况的风格076
这是一篇文章1好几份送二代更何况的风格147
这是一篇文章2好几份送二代更何况的风格229
这是一篇文章3好几份送二代更何况的风格312
这是一篇文章4好几份送二代更何况的风格47
这是一篇文章5好几份送二代更何况的风格574
这是一篇文章6好几份送二代更何况的风格694
这是一篇文章7好几份送二代更何况的风格750
这是一篇文章8好几份送二代更何况的风格86
这是一篇文章9好几份送二代更何况的风格976
  • 总共 50 条
  • 1
  • 2
  • 3
  • 4
  • 5
  • 10 / page
    Go to
展开查看
vue
<template>
<div class="example">
     <NwTable
          :columns="columns"
          :data-source="tableData"
          title="简单表格"
          :showTableSetting="true"
          :show-index-column="false"
          :rowSelection="{ type: 'radio' }"
          :bordered="true"
          :actionColumn="actionColumn"
          @change="tableChange"
        >
          <template #expandedRowRender="{ record }">
            <span>id: {{ record.id }} </span>
          </template>
          <!-- <template #tableSearch>
            <div>查询表单</div>
          </template> -->
          <template #bodyCell="{ column }">
            <template v-if="column.key === 'action'">
              <Button type="link" primary>查看</Button>
              <Button type="text" danger>查看</Button>
            </template>
          </template>
        </NwTable>
</div> 
</template>
<script setup lang="ts">
    const columns = [
      {
        title: "ID",
        dataIndex: "id",
      },
      {
        title: "标题",
        dataIndex: "title",
      },
      {
        title: "内容",
        dataIndex: "desc",
      },
      {
        title: "数值",
        dataIndex: "num",
        customRender: ({ record }: { record: any }) => {
          return record.num + 1;
        },
      },
    ];
    const actionColumn = {
      width: 260,
      title: "操作",
      dataIndex: "action",
      // slots: { customRender: 'action' },
    };
    const tableData = (function () {
      let lists = [];
      for (let i = 0; i < 50; i++) {
        lists.push({
          id: i,
          title: "这是一篇文章" + i,
          desc: "好几份送二代更何况的风格" + i,
          num: Math.floor(Math.random() * 100),
        });
      }
      return lists;
    })();
    const tableChange = (e: any) => {
      console.log(e);
    };
</script>

API

通过设置NwTable的属性可以实现不同的效果。 表格组件的属性说明如下:

属性说明类型默认值
showTableSetting是否显示表格设置booleantrue
autoCreateKey是否自动为每一行数据设置唯一的keybooleanfalse
striped是否展示斑马条纹booleantrue
api远程获取表格数据方法functionnull
beforeFetch获取数据之前处理方法functionnull
afterFetch获取数据之后处理方法functionnull
immediate是否立即请求数据booleantrue
searchInfo额外的请求参数objectnull
fetchSetting请求参数配置object{pageField: 'page', sizeField: 'pageSize', listField: 'items',totalField: 'total'}
columns列配置BasicColumn[]
showIndexColumn收否展示表格序号booleantrue
indexColumnProps序号列配置objectnull
actionColumn操作列objectnull
ellipsis超出的是否自动省略booleantrue
rowSelection列表项是否可选择Objectnull
title表格标题string/functionnull
dataSource表格数据array[]
rowKey表格行 key 的取值,可以是字符串或一个函数string/function''
bordered是否展示表格边框booleantrue
pagination分页信息object/booleannull
loading表格加载中booleanfalse
rowClassName表格行的类名function
size表格sizestringmiddle

column

column和rowSelection 等与ant-design-vue组件大致类似