import { DivModule } from '../module' import { TableBody } from './body' import { TableColumn } from './column' import { TableHeader } from './header' export interface TableOptions { /** * 显示边框. */ bordered?: boolean /** * 数据列表. */ list: T[] /** * 列设置. */ cols: TableColumn[] } /** * 表格. */ export class Table extends DivModule { constructor(opts: TableOptions) { super('wok-ui-table') if (opts.bordered) { this.el.classList.add('bordered') } this.addChild({ tag: 'table', children: [ // 表头 new TableHeader({ cols: opts.cols }), // 主体 new TableBody({ table: this, list: opts.list, cols: opts.cols }) ] }) } }