1 Star 0 Fork 8

丷泡泡o0O/mini-sandbox

forked from buuing/mini-sandbox 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.html 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mini Sandbox</title>
</head>
<body>
<style>
</style>
<style>
body {
position: relative;
height: 100%;
overflow: hidden;
}
#my-sandbox {
box-shadow: 0.8rem 0.8rem 1.4rem #c8d0e7,
-0.2rem -0.2rem 1.8rem #dddfea;
width: 90vw;
height: 80vh;
margin: 10vh auto;
/* border: 2px solid rgb(19, 121, 255); */
border-radius: 5px;
box-sizing: border-box;
}
</style>
<div id="my-sandbox"></div>
<script src="https://cdn.jsdelivr.net/npm/mini-sandbox@0.3.4"></script>
<!-- <script src="./dist/index.umd.js"></script> -->
<!-- <script src="./dist/vue-loader.js"></script> -->
<!-- <script src="./dist/react-loader.js"></script> -->
<script>
var mp = new MiniSandbox({
el: '#my-sandbox',
files: {
'index.html': {
defaultValue: "<style>\n h3 {\n text-align: center;\n }\n</style>\n\n<h3 class=\"box\"></h3>\n",
jsLibs: ['app.js'],
},
'app.js': {
module: 'esm',
defaultValue: `import { getTime } from './utils.js'
const dom = document.querySelector('.box')
setInterval(() => {
dom.innerHTML = '当前时间: ' + getTime()
}, 1000 / 60)`
},
'utils.js': {
module: 'esm',
defaultValue: `const fillZero = str => {
return ('0' + str).slice(-2)
}
export const getTime = (x, y) => {
const dt = new Date()
const h = dt.getHours()
const m = dt.getMinutes()
const s = dt.getSeconds()
return \`\${fillZero(h)}\:\${fillZero(m)}:\${fillZero(s)}\`
}`
}
},
defaultConfig: {
height: '80vh'
}
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/qq1099719995/mini-sandbox.git
git@gitee.com:qq1099719995/mini-sandbox.git
qq1099719995
mini-sandbox
mini-sandbox
master

搜索帮助