Function getTableColumns

  • 生成 table columns 数组

    Parameters

    • fields: {
          align?: "center" | "left" | "right";
          className?: string;
          colSpan?: number;
          dataIndex?: string;
          defaultSortOrder?: string;
          ellipsis?: any;
          fixed?: false | "left" | "right";
          hidden?: boolean;
          key?: string;
          label?: string;
          render?: ((text: any, record: any, index: number) => any);
          search?: any;
          showSearch?: boolean;
          sorter?: any;
          title?: string;
          value?: string;
          width?: string | number;
          [key: string]: any;
      }[]

      基础数据

    Returns {
        align?: "left" | "center" | "right";
        className?: string;
        colSpan?: number;
        dataIndex?: string;
        defaultSortOrder?: "ascend" | "descend" | string;
        ellipsis?: boolean | any;
        fixed?: "left" | "right" | false;
        hidden?: boolean;
        key?: string;
        label?: string;
        render?: ((text: any, record: any, index: number) => any);
        search?: any;
        showSearch?: boolean;
        sorter?: any;
        title?: string;
        value?: string;
        width?: number | string;
        [key: string]: any;
    }[]

    const fields = [
    { label: 'Name', value: 'name' },
    { label: 'Email', key: 'email' },
    { label: 'Age' },
    ];
    const columns = getTableColumns(fields);
    console.log(columns);
    // Output: [
    // { title: 'Name', dataIndex: 'name', key: 'name', label: 'Name', value: 'name' },
    // { title: 'Email', dataIndex: 'email', key: 'email', label: 'Email' },
    // { title: 'Age', dataIndex: 'Age', key: 'Age', label: 'Age' },
    // ]