我正在嘗試復制模式內特定 IFrame 元素中的內容以避免不必要的數據庫調用。我正在通過 Python 調用客戶端回調(請參閱此處),它返回我想在模式中復制的特定 IFrame 元素的索引。這是 Python 代碼片段,它切換我的模式并跟蹤最近單擊的要復制的圖形的索引:@app.callback( [Output('my-modal', 'is_open'), Output('modal-clone', 'children')], [Input(f'button{k}', 'n_clicks_timestamp') for k in range(20)] + [State('my-modal', 'is_open')])def toggle_modal(*data): clicks, is_open = data[:20], data[20] modal_display = not is_open if any(clicks) else is_open clicked = clicks.index(max(clicks)) return [modal_display, clicked]app.clientside_callback( ClientsideFunction(namespace='clientside', function_name='clone_figure'), Output('modal-test', 'children'), [Input('modal-clone', 'children'), Input('modal-figure', 'id')])以及以下 Javascript:window.dash_clientside = Object.assign({}, window.dash_clientside, { clientside: { clone_figure: function(clone_from, clone_to) { source = document.getElementById(clone_from); console.log(document.getElementById(clone_to)) console.log(document.getElementById(clone_to).contentDocument); clone = document.getElementById(clone_to); // set attributes of clone here using attributes from source return null } }});現在,從我的console.log()陳述中,我注意到以下內容(請注意,modal-clone在屏幕截圖中對應modal-figure于我的示例):contentDocument這兩個日志語句之間的變化如何?任何見解將不勝感激,我很難過。
SVG 內容從 IFrame 文檔內容中消失
慕后森
2022-12-09 19:46:10