我有一个基于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>
);
}
结果如下:
我确定我一定会丢失某些东西,我丢失了什么,为什么它没有显示为表格?
最佳答案
您没有导入CSS。 Table
组件是唯一需要CSS设置flexbox样式的组件。
签出the docs:
// 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'