commit 65d4dc3f21e470c424d47dbb5f79fce7bf21fafe Author: gitadmin Date: Wed Nov 18 16:25:01 2026 +0800 init: 示例工程 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e25472e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# simple-web + +最小前端示例:`index.html` + `app.js` + `style.css`,按钮点击后调用 `createOrder` 并渲染列表。 diff --git a/app.js b/app.js new file mode 100644 index 0000000..a107ca7 --- /dev/null +++ b/app.js @@ -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 => `
  • ${o.id} × ${o.quantity}
  • `).join(''); +} + +document.getElementById('btn').addEventListener('click', () => { + orders.push(createOrder('SKU-001', 1)); + render(); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..9731110 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + Simple Web Demo + + + +

    Simple Web Demo

    +

    点击按钮调用本地函数

    + + + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..f590ef2 --- /dev/null +++ b/style.css @@ -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; }