反应虚拟化表未呈现为表

Chr*_*sco 4 reactjs react-virtualized

我有一个基于demo编写的超级基本示例,但它不起作用:

import React from 'react';
import {
  Table,
  Column,
} from 'react-virtualized'

function MyTable(props) {
  return (
    <Table
      width={ 900 }
      height={ 500 }
      headerHeight={ 30 }
      rowHeight={ 30 }
      rowCount={ props.list.length }
      rowGetter={ ({ index }) => props.list[index] }
    >
      <Column
        width={ 250 }
        dataKey={ 'id' }
        headerRenderer={ ({ dataKey }) => 'Id' }
      />
      <Column
        width={ 250 }
        dataKey={ 'title' }
        headerRenderer={ ({ dataKey }) => 'Title' }
      />
    </Table>
  );
}
Run Code Online (Sandbox Code Playgroud)

这是结果:

在此处输入图片说明

我确定我一定遗漏了什么,我遗漏了什么,为什么它没有显示为表格?

bva*_*ghn 7

您没有导入 CSS。该Table组件是唯一需要 CSS 来设置 flexbox 布局样式的组件。

查看文档

// Most of react-virtualized's styles are functional (eg position, size).
// Functional styles are applied directly to DOM elements.
// The Table component ships with a few presentational styles as well.
// They are optional, but if you want them you will need to also import the CSS file.
// This only needs to be done once; probably during your application's bootstrapping process.
import 'react-virtualized/styles.css'

// You can import any component you want as a named export from 'react-virtualized', eg
import { Column, Table } from 'react-virtualized'
Run Code Online (Sandbox Code Playgroud)