simple-web/app.js
2026-11-18 16:25:01 +08:00

17 lines
463 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 最小前端示例:按钮 → 下单 → 渲染列表
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();
});