hag*_*wal 5 python python-3.x plotly-dash
Dash App 中需要有一个回调函数来执行某些操作然后刷新页面,只能使用 HTML A 标签实现页面重新加载。
html.A(html.Button('Refresh Data'),href='/')
Run Code Online (Sandbox Code Playgroud)
必需的:
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 ?
Run Code Online (Sandbox Code Playgroud)
我想这是正确的方法:
将其添加到您的布局中:
dcc.Location(id='url', refresh=True),
Run Code Online (Sandbox Code Playgroud)
打回来:
@app.callback(
Output("url", "href"),
Input("App-logo", "n_clicks"),
prevent_initial_call=True,
)
def reload_data(_):
return "/"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5620 次 |
| 最近记录: |