问题描述
我有一个两页应用程序,在第一页(app.py)上,我使用dcc.Store将值存储在会话缓存中,然后尝试在第二页中加载此数据(app2.py ),并将其显示为html.H1。
i have a 2-page app, on the first page (app.py), i use dcc.Store to store a value in the session cache, and then trying to load this data in the 2nd page (app2.py), and show it as html.H1.
这是我在第一页中的代码:
Here is my code in page one:
dcc.Store(id='session', storage_type='session'),
然后我在此页面上的回调是:
then my callback on this page is:
@app.callback(Output('session', 'data'),
[Input('q1', 'value')])
def q1_value(q1):
return {'answer1value': q1}
同时 q1
但是当我运行此应用程序时,此H1中没有任何显示。我花了很多时间解决此问题,但失败了,有人可以帮忙吗?
But when i run this app, nothing is shown up in this H1. I have spent many hours fixing this but fail, would anyone please help ?
推荐答案
放入您的
dcc.Store(id='session', storage_type='session'),
在app.py而不是page1.py上的
onto the app.py, not page1.py, under the
app.layout = html.Div([....])
然后,您的值将存储在此处,并可从其他页面调用。
then your value will be stored here, and can be called from other pages.
这篇关于使用dcc.Store在另一个页面中进行Plotly Dash Share回调输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!