gpt4 book ai didi

html - 错误 : object was provided as `children` instead of a component, 字符串或数字(或它们的列表)

转载 作者:行者123 更新时间:2023-12-05 06:10:02 25 4
gpt4 key购买 nike

我似乎无法找出开发者控制台中弹出此错误的原因。该脚本在 R 中完美运行并且之前已经工作过。我记得从脚本中删除了一个回调,仅此而已。下面是包含应用程序布局 html 部分的 R 脚本。有人可以帮忙吗?

app$layout(
htmlDiv(
children = list(
htmlDiv(
list(
htmlDiv(
list(
htmlH3(
"Maternal Health Dashboard",
style=list("margin-bottom"= "0px",
"text-align" = "center")
)
)
)
),
className="row flex-display",
id="title",
style=list("margin-bottom"= "25px")
),
htmlDiv(
list(
htmlP("Tabs", className="tabs"),
dccRadioItems(
id="tab_buttons",
options = list(
list("label"= "General", "value"= "general"),
list("label"= "Antenatal", "value"= "antenatal_risk"),
list("label"= "Postnatal ", "value"= "postnatal_details"),
list("label"= "LBW Child ", "value"= "LBW_details")
),
value="general",
labelStyle=list("display"= "inline-block","text-align" = "center"
),
className="dcc_control"
)
)
),
htmlDiv(
id = "map-container",
list(
htmlP("Map of Maternal Health",
id = "map-title",
),
dccGraph(figure=fig
)
)
),
htmlDiv(
list(
htmlP("Total GP "),
htmlP("Total Sub Centers "),
htmlP("Total Villages "),
htmlP("Total Beneficiary Women "),
htmlP("Total Postnatal Women "),
htmlP("Total Neonatal Women ")
),
style= list("display"= "flex","border"= "2px solid powderblue","white-space" = "normal", "justify-content" = "space-around"),
id="info-container",
className="row container-display"
),
htmlDiv(
id = "graph-container",
list(
htmlP(id="chart-selector",
children = "Select chart:"
),
dccDropdown(
options = list(list("label"= "Total number of infants per Woman ",
"value"= "show_absolute_deaths_single_year"),
list("label"= "COVID-19 Cases",
"value"= "absolute_deaths_all_time"),
list("label"= "Total number of post-natal immunizations",
"value"= "show_death_rate_single_year"),
list("label"= "",
"value"= "death_rate_all_time")),
value="show_death_rate_single_year",
id="chart-dropdown"
),
dccGraph(
id = "selected-data"
)
)
),
id="mainContainer",
style = list(
"position" = "relative",
"box-sizing" = "border-box"
)
)))


app$run_server()

最佳答案

我用 Python 而不是 R 编写 Dash,但我怀疑行为非常相似,您的问题来自这两个地方:

      htmlDiv(
id = "map-container",
list(
htmlP("Map of Maternal Health",
id = "map-title",
),
dccGraph(figure=fig
)
)
),
      htmlDiv(
id = "graph-container",
list(
htmlP(id="chart-selector",
children = "Select chart:"
),
dccDropdown(
options = list(list("label"= "Total number of infants per Woman ",
"value"= "show_absolute_deaths_single_year"),
list("label"= "COVID-19 Cases",
"value"= "absolute_deaths_all_time"),
list("label"= "Total number of post-natal immunizations",
"value"= "show_death_rate_single_year"),
list("label"= "",
"value"= "death_rate_all_time")),
value="show_death_rate_single_year",
id="chart-dropdown"
),
dccGraph(
id = "selected-data"
)
)
),

默认情况下,Dash 组件期望 children 属性是第一个传入的东西。在这些情况下,您首先提供了 id,但还没有显式设置 children=,因此它不知道如何处理该组件。要么将它们显式设置为 children,要么将它们设置为组件的第一个对象。

关于html - 错误 : object was provided as `children` instead of a component, 字符串或数字(或它们的列表),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64581880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com