Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我在angular应用程序中有vendor.js和main.js,我想延迟加载这些脚本_Angular_Deferred Loading - Fatal编程技术网

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

我在angular应用程序中有vendor.js和main.js,我想延迟加载这些脚本,angular,deferred-loading,Angular,Deferred Loading,在下面的图片中,我在angular app中看到了vendor.js和main.js,我想延迟加载这些脚本,但在我的项目中应该在哪里加载呢 这是我的组件 getProductById(id: any): any { return this.products.find((product) => product._id === id); } increase(id: any): void { let product = this.getProductById(id

在下面的图片中,我在angular app中看到了vendor.js和main.js,我想延迟加载这些脚本,但在我的项目中应该在哪里加载呢 这是我的组件


  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
文件,并删除加载这些文件的相关脚本标记。

检查index.html文件,并删除加载这些文件的相关脚本标记。@VinaySomawat index.html中没有脚本标记index.html中没有脚本标记,htmlUser全局搜索这些文件,从中加载并注释part.cannot find vendor.ts,并且my angular.json中有main.ts