微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我在 angular 应用中有 vendor.js 和 main.js,我想推迟加载这些脚本

如何解决我在 angular 应用中有 vendor.js 和 main.js,我想推迟加载这些脚本

my console screenshot 在下面的图像中,我在 angular 应用程序中有 vendor.js 和 main.js,我想推迟加载这些脚本,但在我的项目中在哪里执行 这是我的组件。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;
  }
}

index.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>

解决方法

检查根文件夹中的 index.html 文件,并删除加载这些文件的相关脚本标记。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。