Skip to content

Commit 6526ae0

Browse files
committed
refactor: 更新渲染逻辑
1 parent c599322 commit 6526ae0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/BootstrapBlazor/Components/IFrame/IFrame.razor.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import Data from "../../modules/data.js"
22

3-
export function init(id, invoke, callback) {
3+
export function init(id, invoke, options) {
4+
const { data, triggerPostDataCallback, triggerLoadedCallback } = options;
45
const handler = e => {
5-
invoke.invokeMethodAsync(callback, e.data)
6+
invoke.invokeMethodAsync(triggerPostDataCallback, e.data)
67
}
78
Data.set(id, handler)
89

9-
window.addEventListener('message', handler);
1010
const frame = document.getElementById(id);
1111

1212
frame.onload = () => {
13-
invoke.invokeMethodAsync("TriggerLoaded");
13+
invoke.invokeMethodAsync(triggerLoadedCallback);
14+
window.addEventListener('message', handler);
15+
if (data) {
16+
frame.contentWindow.postMessage(data);
17+
}
1418
}
1519
}
1620

0 commit comments

Comments
 (0)