首页 > 解决方案 > Angular项目自己编译/刷新页面

问题描述

几分钟后,我通过运行ng serveangular cli 编译项目并自行多次刷新页面来运行 angular 项目,尽管代码中没有更新/更改

 Date: 2019-07-18T08:23:29.120Z - Hash: 05d5fccc26f4af73d3 - Time: 502ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.
 i 「wdm」: Compiling...

 Date: 2019-07-18T08:28:50.519Z - Hash: 05d5fccc26f4af73d3 - Time: 869ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.
 i 「wdm」: Compiling...

 Date: 2019-07-18T08:47:26.476Z - Hash: 05d5fccc26f4af73d3 - Time: 710ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.

angular cli没有错误,只是显示了多个编译日志

标签: angular

解决方案


就我而言,我有一个未处理的 http 请求。一旦我添加了一个异常,问题就停止了。

  private handleError(error: HttpErrorResponse) {
    if (error.error instanceof ErrorEvent) {
      // A client-side or network error occurred. Handle it accordingly.
      console.error('An error occurred:', error.error.message);
    } else {
      // The backend returned an unsuccessful response code.
      // The response body may contain clues as to what went wrong.
      console.error(
        `Backend returned code ${error.status}, ` +
        `body was: ${error.error}`);
    }
    // Return an observable with a user-facing error message.
    return throwError(
      'Something bad happened; please try again later.');
  }

  // settings
  getSettings(): Observable<Settings> {
    return this.http.get<Settings>(`${this.localUrl}getSettings`)
      .pipe(map(response => response))
      .pipe(catchError(this.handleError))
  }

推荐阅读