init: 示例工程

This commit is contained in:
gitadmin 2026-11-18 16:25:01 +08:00
commit 65d4dc3f21
4 changed files with 38 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# simple-web
最小前端示例:`index.html` + `app.js` + `style.css`,按钮点击后调用 `createOrder` 并渲染列表。

16
app.js Normal file
View File

@ -0,0 +1,16 @@
// 最小前端示例:按钮 → 下单 → 渲染列表
const orders = [];
function createOrder(sku, quantity) {
return { id: `ORD-${sku}-${orders.length + 1}`, sku, quantity };
}
function render() {
const list = document.getElementById('list');
list.innerHTML = orders.map(o => `<li>${o.id} × ${o.quantity}</li>`).join('');
}
document.getElementById('btn').addEventListener('click', () => {
orders.push(createOrder('SKU-001', 1));
render();
});

15
index.html Normal file
View File

@ -0,0 +1,15 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>Simple Web Demo</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Simple Web Demo</h1>
<p id="hint">点击按钮调用本地函数</p>
<button id="btn">下单</button>
<ul id="list"></ul>
<script src="app.js"></script>
</body>
</html>

4
style.css Normal file
View File

@ -0,0 +1,4 @@
body { font-family: -apple-system, "PingFang SC", sans-serif; margin: 40px; }
h1 { font-size: 20px; }
button { padding: 6px 14px; }
ul { margin-top: 16px; }