admin管理员组文章数量:1289362
I'm trying to render a very simple table with React and the Blueprint UI toolkit.
The documentation relative to the Table
ponent is quite simple, but it seems like my code doesn't work.
import React from 'react';
import ReactDOM from 'react-dom';
import * as Blueprint from '@blueprintjs/core';
import { Cell, Column, Table } from '@blueprintjs/table';
const renderCell = (rowIndex: number) => {
return <Cell>{`$${(rowIndex * 10).toFixed(2)}`}</Cell>
};
var myTable = (
<Table numRows={10}>
<Column name="Dollars" renderCell={renderCell}/>
</Table>
);
ReactDOM.render(
myTable,
document.getElementById('myTable')
);
The image below shows what I get. How do I fix it?
I'm trying to render a very simple table with React and the Blueprint UI toolkit.
The documentation relative to the Table
ponent is quite simple, but it seems like my code doesn't work.
import React from 'react';
import ReactDOM from 'react-dom';
import * as Blueprint from '@blueprintjs/core';
import { Cell, Column, Table } from '@blueprintjs/table';
const renderCell = (rowIndex: number) => {
return <Cell>{`$${(rowIndex * 10).toFixed(2)}`}</Cell>
};
var myTable = (
<Table numRows={10}>
<Column name="Dollars" renderCell={renderCell}/>
</Table>
);
ReactDOM.render(
myTable,
document.getElementById('myTable')
);
The image below shows what I get. How do I fix it?
Share Improve this question edited Jan 6, 2017 at 17:57 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Nov 23, 2016 at 6:39 LukeLuke 3,0467 gold badges35 silver badges45 bronze badges4 Answers
Reset to default 8Are you including blueprint.css
and blueprint-table.css
on your page? The Table won't render correctly without its stylesheets!
I had to include this line in my css file (using webpack setup by create-react-app):
@import '~@blueprintjs/table/dist/table.css';
For me,
yarn add @blueprintjs/core @blueprintjs/table
Then using a relative path from my react ponent file
import { Cell, Column, Table } from '@blueprintjs/table'
import '../../node_modules/@blueprintjs/table/lib/css/table.css'
import '@blueprintjs/core/dist/blueprint.css'
本文标签: javascriptHow to render a table in React by using BlueprintStack Overflow
版权声明:本文标题:javascript - How to render a table in React by using Blueprint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741465223a2380274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论