我有一个 MWE Dash 应用程序,带有一个可通往其他页面的按钮:
import dash
from dash import dcc
from dash import html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
app = dash.Dash(__name__, suppress_callback_exceptions=True)
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content'),
])
def get_overview_page():
page = html.Div([
dcc.Link(
html.Button('Neu', id='new_button',
style={'margin-left': '10px', 'width': '100px', 'height': '27px',
'fontSize': '16px'}),
href='/new-entry'
),
dbc.Tooltip(
"A.",
target="new_button", placement="top"
)
], style={'width': '30%', 'margin-top': '10px', 'display': 'inline-block', 'text-align': 'left'})
return page
# Update the index
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/new-entry':
return html.Div()
else:
return get_overview_page()
if __name__ == '__main__':
app.run_server(debug=True, port=8086, host='127.0.0.1')
当我按下按钮并随后移动鼠标时,我收到以下错误。 该错误对我来说没有任何意义。这是怎么回事?
对象以
children
的形式提供,而不是组件、字符串或数字(或它们的列表)。检查孩子的财产,看起来像这样:
提供了一个对象作为
而不是组件、字符串、 或数量(或列表)。检查看起来的孩子财产 类似:{“1”:{ “道具”: { “is_open”:假 } } }children
我尝试过的: 当我删除 dbc.Tooltip 时,错误消失了,但我不知道发生了什么,我需要工具提示。
在我看来,这是由加载新页面的回调和关闭 dbc 工具提示的客户端回调之间的竞争条件引起的(将
is_open
设置为 false
)。页面切换回调完成,更新页面的子项,有效地从 DOM 中删除工具提示。然后,客户端回调关闭工具提示,尝试修补不存在的子组件,导致子组件被仅具有 is_open
的部分组件损坏。
我刚刚提交了https://github.com/facultyai/dash-bootstrap-components/issues/997,因为我遇到了同样的问题。