text: from dash import Dash, dcc, html, Input, Output
  import dash_bootstrap_components as dbc
  
  app = Dash(__name__, external_stylesheets=[dbc.themes.COSMO], title="Dash 之 链式回调")
  
  选项 = {
      "广西壮族自治区": ["南宁市", "桂林市", "北海市"],
      "山东省": ["青岛市", "济南市", "日照市"],
  }
  app.layout = html.Div(
      [
          html.P(),
          html.H1("链式回调"),
          dcc.RadioItems(list(选项.keys()), "广西壮族自治区", id="省份"),
          html.Hr(),
          dcc.RadioItems(id="城市"),
          html.Hr(),
          html.Div(id="输出位置"),
      ]
  )
  
  
  @app.callback(
      Output("城市", "options"),
      Input("省份", "value"),
  )
  def 更新城市(省份):
      return [{"label": i, "value": i} for i in 选项[省份]]
  
  
  @app.callback(
      Output("城市", "value"),
      Input("城市", "options"),
  )
  def 初始化城市(城市):
      return 城市[0]["value"]
  
  
  @app.callback(
      Output("输出位置", "children"),
      Input("省份", "value"),
      Input("城市", "value"),
  )
  def 输出选择(省份, 城市):
      return f"你选择了 {省份} 的 {城市}"
  
  
  if __name__ == "__main__":
      app.run_server(debug=True)
  