如何修复:组件的 Children 属性是列表的列表,而不仅仅是 Python 中带有 Plotly-dash 的列表

JA-*_*sta 5 python-3.x plotly plotly-dash plotly-python

我正在尝试使用绘图和破折号构建一个简单的网络仪表板。这是我想要获得的结构:

app = dash.Dash(__name__)

def Build_home_page():
    """
    build_welcome_banner [summary]

    [extended_summary]

    Returns
    -------
    [type]
        [description]
    """    ""
    
    return [
        html.Div(
            id="banner",
            className="box",
            children=[
                html.Div(
                    id="welcome-user",
                    children=[
                        html.H1("WELCOME TO THE DATA SCIENCE"),
                        html.H1("AND MACHINE LEARNING PLATFORM"),
                        html.Hr(className="tickline"),
                        html.Br(),
                        html.P(id="welcome-text1",
                               children= [
                                   "That provides you with the tools that allow you to explore your data seemlessly and"
                                   ]),
                        html.P(id= "welcome-text2",
                               children= [
                                   "get actionable insights from your data and allows you to easily apply Machine learning models to make predictions with your data"
                                   ]),
                                ],
                        ),
                    ],
        ), 
        
        html.Div(
            id= "features",
            className= "features-box-model",
            children=[
                html.Div(
                    id= "feature-text",
                    children= [
                        html.Div("Features"),
                    ],
                ),
            ],
        ),
    ]


app.layout = html.Div(
    id="get-started-page",
    children=[
        Build_home_page(),
        
    ],
)


if __name__ == '__main__':
    app.run_server(debug=True,
                   use_reloader=False, 
                   port=8080)
Run Code Online (Sandbox Code Playgroud)

然后我收到以下错误:The children property of a component is a list of lists, instead of just a list. Check the component that has the following contents, and remove one of the levels of nesting:

可能出什么问题了?我检查了我的清单,看起来还不错!每个孩子周围都堆满了一张清单。我不知道问题出在哪里

emh*_*her 9

您已将最外层的子级包装Div在列表中两次,无论是在Build_home_page布局定义内还是在布局定义中,您应该删除其中之一。删除后者,布局定义将是

app.layout = html.Div(
    id="get-started-page",
    children=Build_home_page()
)
Run Code Online (Sandbox Code Playgroud)