angular - 我在 Angular 应用中有 vendor.js 和 main.js,我想推迟加载这些脚本
问题描述
下图中的控制台屏幕截图我在 Angular 应用程序中有 vendor.js 和 main.js,我想推迟加载这些脚本,但是在我的项目中执行它的位置是我的 component.ts
getProductById(id: any): any {
return this.products.find((product) => product._id === id);
}
increase(id: any): void {
let product = this.getProductById(id);
product.quantity = product.quantity + 1;
}
decrease(id: any): void {
let product = this.getProductById(id);
if (product.quantity > 0) product.quantity = product.quantity - 1;
}
addToCart(id: any): void {
let product = this.getProductById(id);
this.totalItem = this.totalItem + product.quantity;
}
}
索引.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DeferLoding</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography">
<app-root></app-root>
</body>
</html>
解决方案
推荐阅读
- c# - 用于 xml 架构编译的 Full Framework 和 .NET Core 的不同行为
- angular - 让 toast 允许单击悬停时背后的元素,例如 Skype 通知
- php - 带有可选参数的 Laravel 函数
- angular - 过滤和分页不适用于 ngxpagination 模板
- php - 从复选框插入的许多值只有最后一个值插入到数据库中
- javascript - 在gridview上的每一行Highchart数据以在按钮单击打开模式上显示不同的数据
- excel - 如何使用 VBA 通过 Pivot 切片器进行过滤?
- css - 是否可以通过 CSS 停止传播?
- spring - 用于 Spring 集成消息处理程序的 Bean 注入
- java - logback 创建 appender 的新实例