Dash总结

dbc

dbc.Store 存储数据

dcc.Store(id='Store_data_xlsx'),
dbc.Button(id = 'test_Store'),
html.Div(id='Store_data_xlsx_div'),

@callback(
        Output('Store_data_xlsx', 'data'),
        Input('test_Store', 'n_clicks'),
)
def save_1(n_clicks):
    if n_clicks:
        # 获取当前日期
        current_date = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
        return {'data': current_date}

@callback(
        Output('Store_data_xlsx_div', 'children'),
        Input('Store_data_xlsx', 'data'),
)
def show_data_xlsx(data):
    if data:
        return f"当前日期:{data}"
    else:
        return "未保存数据"

你可能感兴趣的:(dash,python,前端)