From 65d4dc3f21e470c424d47dbb5f79fce7bf21fafe Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 18 Nov 2026 16:25:01 +0800 Subject: [PATCH] =?UTF-8?q?init:=20=E7=A4=BA=E4=BE=8B=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ app.js | 16 ++++++++++++++++ index.html | 15 +++++++++++++++ style.css | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 README.md create mode 100644 app.js create mode 100644 index.html create mode 100644 style.css 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; }