解决方法:一个组件的children 属性是一个列表的列表,而不仅仅是Python中有Plotly-dash的列表

How to fix: The children property of a component is a list of lists, instead of just a list with Plotly-dash in Python

我正在尝试使用 plotly 和 dash 构建一个简单的网络仪表板。这是我试图获得的结构:

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)

然后我得到以下错误: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:

有什么问题吗?我检查了我的清单,似乎没问题!每个 children 周围都有一个列表。我不知道问题出在哪里

您已将最外层 Div 的子级包裹在列表中两次,在 Build_home_page 内部和布局定义中,您应该删除其中一个。删除后者,布局定义将是

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