【发布时间】:2021-11-26 12:46:43
【问题描述】:
我正在尝试在 Plotly Dash 中进行客户端回调,其中将执行 JavaScript 脚本。我在脚本的其他地方定义了一个 Python 变量,现在我想将该变量传递给我有我的脚本的客户端回调。这是代码的sn-p:
python_variable = 'string or some variable'
app.clientside_callback(
"""
function(n_clicks, user_input) {
if (n_clicks){
alert(%{user_input} + %{python_variable});
}
}
""",
Output('dummy_div', 'children'),
[Input('btn', 'n_clicks'),
Input('user_input', value)]
我不知道如何将我的 python_variable 放在 dcc.Store 中,因为我在页面加载期间加载变量(对此没有回调)。是否可以将我的 Python 变量添加到我的客户端回调函数中?
【问题讨论】:
标签: javascript python plotly plotly-dash client-side