66 onMounted ,
77 onUnmounted ,
88 ref ,
9+ useTemplateRef ,
910 watch ,
1011 watchEffect ,
1112} from ' vue'
@@ -19,7 +20,7 @@ const props = defineProps<{ show: boolean; ssr: boolean }>()
1920const { store, clearConsole, theme, previewTheme, previewOptions } =
2021 inject (injectKeyProps )!
2122
22- const container = ref < HTMLDivElement >( )
23+ const containerRef = useTemplateRef ( ' container ' )
2324const runtimeError = ref <string >()
2425const runtimeWarning = ref <string >()
2526
@@ -68,7 +69,7 @@ function createSandbox() {
6869 // clear prev sandbox
6970 proxy .destroy ()
7071 stopUpdateWatcher && stopUpdateWatcher ()
71- container .value ?.removeChild (sandbox )
72+ containerRef .value ?.removeChild (sandbox )
7273 }
7374
7475 sandbox = document .createElement (' iframe' )
@@ -101,7 +102,7 @@ function createSandbox() {
101102 previewOptions .value ?.placeholderHTML || ' ' ,
102103 )
103104 sandbox .srcdoc = sandboxSrc
104- container .value ?.appendChild (sandbox )
105+ containerRef .value ?.appendChild (sandbox )
105106
106107 proxy = new PreviewProxy (sandbox , {
107108 on_fetch_progress : (progress : any ) => {
@@ -280,7 +281,7 @@ function reload() {
280281 sandbox .contentWindow ?.location .reload ()
281282}
282283
283- defineExpose ({ reload , container })
284+ defineExpose ({ reload , container: containerRef })
284285 </script >
285286
286287<template >
0 commit comments