如何获取 Dash 中的当前路径?

Tla*_*-ES 5 python plotly-dash

我试图获取 URL 的当前路径以便对过滤器进行操作,但是当我调用时dcc.Location.pathname无法获取 URL。

知道如何获得它吗?

我尝试过print(Input('url', 'pathname'))但也不起作用。

任何想法?

谢谢

cor*_*nda 2

用作Input('url', 'pathname')回调的输入并在那里构建过滤器。

就像是:

@app.callback(
    Output('my-output', 'children'),
    [Input('url', 'pathname')])
def callback_func(pathname):
    # here you can use the pathname however, just like a normal function input
    print(pathname)
Run Code Online (Sandbox Code Playgroud)