【发布时间】:2021-08-23 02:48:53
【问题描述】:
您好,我正在尝试在 JS 中使用提示符获取输入,该输入稍后会传递到常规回调中,然后打印在屏幕上,这是我的破折号代码和 custom-script.js 代码
dash.py:
import dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input,Output,State,ClientsideFunction
app=dash.Dash()
server = app.server
app.layout=html.Div([
dcc.Store(id='error',data={}),
html.Div(id='output')
])
app.clientside_callback(
ClientsideFunction(
namespace='clientside',
function_name='error_text'
),
Output('error','data')
)
@app.callback(Output('output','children'),
[Input('error','data')])
def error_text(error):
return error
if __name__ == '__main__':
app.run_server(debug=True)
assets/custom-script.js:
window.dash_clientside = Object.assign({}, window.dash_clientside, {
clientside: {
error_text: function() {
var error=prompt('enter the error text');
if(error!==null){
return {errorText:error};
}
}
}
});
当我运行我的 dash 应用程序时,提示即客户端脚本根本不起作用,并且我收到常规回调错误,例如回调输入为无,请帮助我
错误信息:
**
在输出的回调中:
错误数据
没有Input 元素。
没有Input 元素,它永远不会被调用。
订阅Input 组件将导致
每当它们的值发生变化时调用回调。
**
【问题讨论】:
标签: javascript callback plotly-dash