react-native表格組件的使用

今天簡單說一下react-native平臺上比較好用的表格組件的使用方法: 組件地址:react-native-table-component 第一步,添加依賴react

yarn add react-native-table-component
複製代碼

第二步,在須要的功能頁面導入組件git

import {Row, Rows, Table} from 'react-native-table-component';
複製代碼

第三步,定義顯示數據github

const optionsChange = {
            tableHead: ['變動項目', '變動前', '變動後'],
            tableData: [
                ['',
                '資方姓名',
                '45.5%'
                ],
                ['',
                '企業名稱',
                '8.9%'
                ],
            ]
        };
複製代碼

第四步,在render函數中添加組件react-native

<View style={{padding: 20}}>
         <Table borderStyle={{borderWidth: 1, borderColor: '#f0f'}}>
               <Row data={options.tableHead} style={styles.head} textStyle={styles.text}/>
                <Rows data={options.tableData} textStyle={styles.text}/>
         </Table>
</View>
複製代碼

最後,來看一下效果如何,仍是至關不錯的 bash

在這裏插入圖片描述
相關文章
相關標籤/搜索