2016-11-23 6 views
1

非常に単純なテーブルをReactとBlueprint UIツールキットでレンダリングしようとしています。Blueprintを使用してReactでテーブルをレンダリングする方法

Tableのコンポーネントに関連するdocumentationは非常に単純ですが、私のコードは機能しません。

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') 
); 

以下の画像は、私が得るものを示しています。どうすれば修正できますか?

Enter image description here

答えて

5

あなたのページのblueprint.cssblueprint-table.cssを含めていますか?テーブルはスタイルシートなしで正しくレンダリングされません!

+0

私は同じ問題を抱えていますが、提案されたインクルードはwebpackを使用するボイラープレートでは動作しません。また、@blueprintjsモジュール名の@、任意のアイデアのためにrequire()にcssは含まれませんか? – perrohunter

+0

興味深い...これは[table install docs](http://blueprintjs.com/docs/#table-js.installation)にありません。私の場合、ファイルは 'node_modules/@blueprintjs/table/dist/table.css'にあります(異なるcssファイル名に注意してください)。 – webelo

-2

'blueprintjs /コア/ DIST/blueprint.css @' インポート

1

私は(作成反応するアプリによってWebPACKのセットアップを使用して)私のCSSファイルに次の行を含める必要がありました:

@import '[email protected]/table/dist/table.css'; 
関連する問題