简体   繁体   English

Plotly Dash Share Callback input in another page with dcc.Store

[英]Plotly Dash Share Callback Input in another page with dcc.Store

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.我有一个 2 页的应用程序,在第一页 (app.py) 上,我使用 dcc.Store 在 session 缓存中存储一个值,然后尝试在第二页 (app2.py) 中加载此数据,并且显示为 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}

while "q1" is a value from my radioitem.而“q1”是我的无线电项目的一个值。

But when i run this app, nothing is shown up in this H1.但是当我运行这个应用程序时,这个 H1 中没有显示任何内容。 I have spent many hours fixing this but fail, would anyone please help?我花了很多时间解决这个问题但失败了,有人可以帮忙吗?

put your把你的

dcc.Store(id='session', storage_type='session'),

onto the app.py, not page1.py, under the到 app.py,而不是 page1.py,在

app.layout = html.Div([....])

then your value will be stored here, and can be called from other pages.那么你的值将存储在这里,并可以从其他页面调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM