Skip to content

Commit 7050004

Browse files
committed
feat: 更新加载逻辑
1 parent c9eadaf commit 7050004

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@ export function init(id, invoke, callback) {
66
}
77
Data.set(id, handler)
88

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

12-
export function execute(id, data) {
13-
const frame = document.getElementById(id)
14-
if (frame) {
15-
if (frame.loaded) {
16-
frame.contentWindow.postMessage(data)
17-
}
18-
else {
19-
frame.onload = () => {
20-
frame.loaded = true
21-
frame.contentWindow.postMessage(data)
22-
}
23-
}
12+
frame.onload = () => {
13+
invoke.invokeMethodAsync("TriggerLoaded");
2414
}
2515
}
2616

17+
export async function execute(id, data) {
18+
const frame = document.getElementById(id);
19+
frame.contentWindow.postMessage(data);
20+
}
21+
2722
export function dispose(id) {
2823
const handler = Data.get(id)
2924
Data.remove(id)

0 commit comments

Comments
 (0)