示例工程 16-iframe-embed
16-iframe-embed/app/assets/sandbox-widget.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>沙箱组件</title>
<style>
body { margin: 0; padding: 16px; background: #f0fdf4; color: #14532d; font-family: system-ui, sans-serif; line-height: 1.6; }
h2 { margin: 0 0 8px; font-size: 18px; }
p { margin: 0 0 6px; font-size: 14px; }
#status { font-weight: 600; }
</style>
</head>
<body>
<h2>沙箱组件</h2>
<p id="status">脚本未运行</p>
<script>
document.getElementById("status").textContent = "脚本已在沙箱中运行";
</script>
</body>
</html>