自己的角度项目编译/刷新页面

时间:2019-07-18 09:01:59

标签: angular

运行角度项目后几分钟,我运行ng serve角度cli编译项目并多次刷新页面,尽管代码没有更新/更改

 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.

角度cli中没有错误,只显示了多个编译日志

1 个答案:

答案 0 :(得分:0)

就我而言,我有一个未处理的 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))
  }