当我“查看源代码”时,我无法从 api 的 http 请求中获取任何员工,看起来员工不是来自服务器。
所以我可以在源代码中看到静态 html,但在 http 请求中什么也看不到....
有人知道什么是问题吗?
我正在使用 universal-cli
编辑:
这是来 self 的 showcode.service.ts
的 http 调用示例:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { environment } from '../../environments/environment';
@Injectable()
export class ShowcodeService {
constructor(private http: Http) { }
getCode(id): any{
return this.http.get(environment.baseUrl + 'code/show/' + id)
.map((response: Response) => response.json());
};
}
这是一个活生生的例子:http://pushsc.com/show/code/58bc83760a58d602a0b99d14检查 html 的源代码...它呈现出 evertying 期望来自 http 的东西...
最佳答案
尝试将您的 Angular 更新为 4.0.0。
他们修复了一些与服务器端渲染相关的错误。
关于angular - 服务器端不呈现 http 请求 [Angular Universal],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42742169/