如何解决Dash绘图中的重复回调输出错误



在输出的回调中:page-content.children输出0(page-content.children(已在使用中。任何给定的输出只能有一个回调来设置它。要解决这种情况,请尝试将这些组合一个回调函数,区分触发器必要时使用CCD_ 1。

当我运行达世币应用程序时,我遇到了上述错误。有人能帮我解决这个问题吗。

这是我的布局部分

html.Div([
dbc.Row(
[
dbc.Col(dbc.NavbarBrand(dcc.Link(
html.Button(children='HOME',
style={
'marginLeft': '100px',
'marginRight': 'auto',
'display': 'inline-block',
'align': 'center', 'color': 'white'}, ),
href='/', refresh=True))),
dbc.Col(dbc.NavbarBrand(dcc.Link(
html.Button(children='OVERVIEW',
style={'margin-left': '100px',
'margin-right': 'auto', 'color': 'white', 'align': 'center'
}),
href='/apps/overview', refresh=True))),
dbc.Col(dbc.NavbarBrand(dcc.Link(
html.Button(children='GRAPH',
style={'marginLeft': '100px',
'marginRight': 'auto', 'color': 'white', 'align': 'center'
}),
href='/apps/graph_page', refresh=True))),
dbc.Col(dbc.NavbarBrand(dcc.Link(
html.Button(children='CONSOLE',
style={'marginLeft': '100px',
'marginRight': 'auto', 'color': 'white', 'align': 'center'
}),
href='/log_stream', refresh=True))),
],
style={
'height': 'auto',
'width': 'auto',
'background-color': '#101820',
'align-items': 'center',
'diplay': 'flex',
},
align="center",
no_gutters=True,
),
dcc.Location(id='url', refresh=False),
html.Div(id='page-content', children=[])
]),
html.Div([
dcc.Dropdown(
id='demo-dropdown',
options=[
{'label': 'Dummy', 'value': 0},
{'label': 'CAN', 'value': 1},
],
placeholder="Select a Mode",
searchable=False
),
html.Div(id='dd-output-container')
])
])

这些是我的回电

@app.callback(
Output('dd-output-container', 'children'),
Input('demo-dropdown', 'value'))
def update_output(value):
return 'You have selected "{}"'.format(value)

@app.callback(Output(component_id='page-content', component_property='children'),
(Input(component_id='url', component_property='pathname')))
def display_page(pathname):
if pathname == '/apps/graph_page':
return graph_page.layout
elif pathname == '/apps/overview':
return overview.layout

提前谢谢。

我在另一个脚本中有一个重复的回调,起初我没有注意到。

  1. 确保布局中的每个组件都有唯一的id
  2. 消除任何脚本中的重复回调

最新更新