You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在多页Dash应用中通过回调调用URL的实现方案咨询

多页Dash应用中通过开关触发页面跳转的回调问题

我正在寻找在多页Dash应用中通过开关调用链接/URL的方法,希望获取关于callback定义的建议。

初始实现思路

html.Div('old', style= {'display':'inline-block', 'float':'left'}), 
html.Div(dcc.Link(daq.BooleanSwitch(id='test-switch', on=False, style= {'display':'inline-block', 'float':'left', 'margin-left': '1px'}), href='/testURL')),

当前回调定义

@app.callback(
Output('boolean-switch-output-1', 'children'),
Input('test-switch', 'on')
)

def render_url(flag):
  if flag == True:
      return '/testURL' # 无法成功跳转到/testURL

其中/testURL已在testURL.py中通过以下代码完成注册:

register_page(__name__, path='/testURL')

临时解决方案

目前我用以下方法作为临时方案:

html.Div('old', style= {'display':'inline-block', 'float':'left'}), 
html.Div(html.A(daq.BooleanSwitch(id='test-switch', on=False, style= {'display':'inline-block', 'float':'left', 'margin-left': '1px'}), href='/testURL', target='_blank'))

提前感谢您的解答。

内容的提问来源于stack exchange,提问作者dark.vador

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 09:55:12