独立 Web 应用开发与 Angular 应用创建指南
1. 独立 Web 应用开发
在开发独立 Web 应用时,数据存储是一个重要环节。以下是一个存储订单数据的函数示例:
storeOrder(): Promise<number> {
let orderData = {
lines: [...this.order.orderLines.values()].map(ol => ({
productId: ol.product.id,
productName: ol.product.name,
quantity: ol.quantity
}))
}
return Axios.post(urls.orders, orderData).then(response => response.data.id);
}
此函数将订单数据整理后通过 Axios 发送 POST 请求到指定 URL,成功后返回订单 ID。URL 遵循常见约定,数据请求以 /api 为前缀。
1.1 构建应用
在 webapp 文件夹中运行以下命令创建生产环境可用的捆绑包:
npx webpack --mode "production"
当 mode <
超级会员免费看
订阅专栏 解锁全文
30

被折叠的 条评论
为什么被折叠?



