【问题标题】:Dash Python App Button for action and refresh the pageDash Python App Button 用于操作并刷新页面
【发布时间】:2020-05-10 17:52:39
【问题描述】:

Dash App中需要有一个回调函数来执行一些动作然后刷新页面,只能使用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):
## Perform some action ##
## call python function API ##
## Finally Refresh the Page ##
 ?
return ?

【问题讨论】:

    标签: python python-3.x plotly-dash


    【解决方案1】:

    我想这是正确的做法:

    将此添加到您的布局中:

    dcc.Location(id='url', refresh=True),
    

    回调:

    @app.callback(
        Output("url", "href"),
        Input("App-logo", "n_clicks"),
        prevent_initial_call=True,
    )
    def reload_data(_):
        return "/"
    

    【讨论】:

      【解决方案2】:

      这应该可以满足您的需要:

      html.A(html.Button('Refresh Page'),href='/'),
      

      【讨论】:

        猜你喜欢
        • 2021-09-21
        • 1970-01-01
        • 1970-01-01
        • 2011-04-23
        • 1970-01-01
        • 2012-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多