60行Python代码轻松搞定数据库查询 1秒找到需要的数据( 三 )


60行Python代码轻松搞定数据库查询 1秒找到需要的数据

文章插图
 
而Th()与Td()均有额外参数colSpan与rowSpan,可以传入整数,来实现横向或纵向「合并单元格」的效果,譬如下面的例子:
?
app3.py
?
import dashimport dash_html_components as htmlimport dash_bootstrap_components as dbcapp = dash.Dash(__name__)app.layout = html.Div(    dbc.Container(        dbc.Table(            [                html.Thead(                    html.Tr(                        [                            html.Th('字段1'),                            html.Th('字段2'),                            html.Th('字段3'),                            html.Th('字段4'),                        ]                    )                ),                html.Tbody(                    [                        html.Tr(                            [                                html.Th('1'),                                # style设置水平居中                                html.Td('colSpan=2', colSpan=2, style={'text-align': 'center'}),                                html.Td('test'),                            ]                        ),                        html.Tr(                            [                                html.Th('2'),                                html.Td('test'),                                # style设置垂直居中                                html.Td('rowSpan=2', rowSpan=2, style={'vertical-align': 'middle'}),                                html.Td('test')                            ]                        ),                        html.Tr(                            [                                html.Th('3'),                                html.Td('test'),                                html.Td('test')                            ]                        )                    ]                )            ],            striped=True,            bordered=True        ),        style={            'margin-top': '50px'  # 设置顶部留白区域高度        }    ))if __name__ == '__main__':    app.run_server(debug=True)


推荐阅读