This commit is contained in:
2025-02-23 23:17:06 +08:00
parent d934111354
commit e275da04ee
8 changed files with 200 additions and 134 deletions

View File

@@ -8,12 +8,11 @@ import { onMounted, useTemplateRef, watch } from "vue"
const iframe = useTemplateRef<HTMLIFrameElement>("iframe")
function preview() {
if (!iframe.value) return
const doc = iframe.value.contentDocument
doc!.open()
doc!.write(`<!DOCTYPE html>
const doc = iframe.value.contentDocument!
doc.open()
doc.write(`<!DOCTYPE html>
<html lang="zh-Hans-CN">
<head>
<meta charset="UTF-8" />
@@ -25,7 +24,7 @@ function preview() {
${html.value}
</body>
</html>`)
doc!.close()
doc.close()
}
watch([html, css], preview)