@@ -19,9 +19,9 @@ const props = defineProps<{ show: boolean; ssr: boolean }>()
19
19
const { store, clearConsole, theme, previewTheme, previewOptions } =
20
20
inject (injectKeyProps )!
21
21
22
- const container = ref ()
23
- const runtimeError = ref ()
24
- const runtimeWarning = ref ()
22
+ const container = ref < HTMLDivElement > ()
23
+ const runtimeError = ref < string > ()
24
+ const runtimeWarning = ref < string > ()
25
25
26
26
let sandbox: HTMLIFrameElement
27
27
let proxy: PreviewProxy
@@ -68,7 +68,7 @@ function createSandbox() {
68
68
// clear prev sandbox
69
69
proxy .destroy ()
70
70
stopUpdateWatcher && stopUpdateWatcher ()
71
- container .value .removeChild (sandbox )
71
+ container .value ? .removeChild (sandbox )
72
72
}
73
73
74
74
sandbox = document .createElement (' iframe' )
@@ -101,7 +101,7 @@ function createSandbox() {
101
101
previewOptions .value ?.placeholderHTML || ' ' ,
102
102
)
103
103
sandbox .srcdoc = sandboxSrc
104
- container .value .appendChild (sandbox )
104
+ container .value ? .appendChild (sandbox )
105
105
106
106
proxy = new PreviewProxy (sandbox , {
107
107
on_fetch_progress : (progress : any ) => {
@@ -169,8 +169,8 @@ async function updatePreview() {
169
169
if (import .meta .env .PROD && clearConsole .value ) {
170
170
console .clear ()
171
171
}
172
- runtimeError .value = null
173
- runtimeWarning .value = null
172
+ runtimeError .value = undefined
173
+ runtimeWarning .value = undefined
174
174
175
175
let isSSR = props .ssr
176
176
if (store .value .vueVersion ) {
@@ -290,7 +290,7 @@ defineExpose({ reload, container })
290
290
class =" iframe-container"
291
291
:class =" { [theme]: previewTheme }"
292
292
/>
293
- <Message :err =" runtimeError && (previewOptions?.showRuntimeError ?? true)" />
293
+ <Message :err =" (previewOptions?.showRuntimeError ?? true) && runtimeError " />
294
294
<Message
295
295
v-if =" !runtimeError && (previewOptions?.showRuntimeWarning ?? true)"
296
296
:warn =" runtimeWarning"
0 commit comments