使用Dash Python应用程序按钮执行操作并刷新页面
在Dash应用程序中需要一个回调函数来执行一些操作,然后刷新页面,使用HTML a标记只能实现页面重新加载使用Dash Python应用程序按钮执行操作并刷新页面,python,python-3.x,plotly-dash,Python,Python 3.x,Plotly Dash,在Dash应用程序中需要一个回调函数来执行一些操作,然后刷新页面,使用HTML a标记只能实现页面重新加载 html.A(html.Button('Refresh Data'),href='/') 所需: app.layout = html.Div([html.Button(id="refresh")]) @app.callback(Output('???', '???'), [Input('refresh', 'n_clicks')]) def refresh(n):
html.A(html.Button('Refresh Data'),href='/')
所需:
app.layout = html.Div([html.Button(id="refresh")])
@app.callback(Output('???', '???'),
[Input('refresh', 'n_clicks')])
def refresh(n):
## Perform some action ##
## call python function API ##
## Finally Refresh the Page ##
?
return ?
这应该满足您的需要:
html.A(html.Button('Refresh Page'),href='/'),
我想这是正确的方法: 将此添加到布局中:
dcc.Location(id='url', refresh=True),
回拨:
@app.callback(
Output("url", "href"),
Input("App-logo", "n_clicks"),
prevent_initial_call=True,
)
def reload_data(_):
return "/"