Prerender.io 和 Angular 通用 - 不在组件标签内呈现 HTML
Prerender.io with Angular Universal - doesn't render HTML within component tags
我创建了一个包含嵌套组件的 Angular 通用应用程序。
我需要 Prerender.io 到 return 服务器端渲染 HTML 从我的应用程序但是 Prerender.io 只有 return 顶级组件标签而不是 HTML内.
似乎每个 Angular 应用(无论是否为 SRR)都会发生这种情况。我希望它发生在 none-SSR 页面上,但不会发生在 SSR 上。
我遵循了 prerender.io 的指南:
git clone https://github.com/prerender/prerender.git
cd prerender
npm install
node server.js
然后试图去:
http://localhost:3000/http://localhost:4000/test
我得到的 returned html 是:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Documents SSR</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="stylesheet" href="styles.3ff695c00d717f2d2a11.css">
<style></style>
</head>
<body>
<app-root _nghost-sc0="" ng-version="8.2.3" _nghost-serverapp-c0="">
<router-outlet _ngcontent-serverapp-c0=""></router-outlet>
<component1>
<!---->
<component2></component2>
</component1>
</app-root>
</body>
</html>
我希望 Prerender.io 渲染 component2
内的所有内容,但如您所见,我什么也没得到。
我是不是在某处缺少配置或者 Prerender.io 不支持 Angular?
如果我直接转到 http://localhost:4000/test
,我会得到完整的渲染图 HTML。
编辑
看起来 Prerender.io 没有等待我的最后一个 ajax 调用完成才渲染?
发现问题 - 不要使用 ShadowDom。
我的 component2
正在使用 encapsulation: ViewEncapsulation.ShadowDom
。
删除让 Prerender 给我整个 HTML.
我创建了一个包含嵌套组件的 Angular 通用应用程序。 我需要 Prerender.io 到 return 服务器端渲染 HTML 从我的应用程序但是 Prerender.io 只有 return 顶级组件标签而不是 HTML内.
似乎每个 Angular 应用(无论是否为 SRR)都会发生这种情况。我希望它发生在 none-SSR 页面上,但不会发生在 SSR 上。
我遵循了 prerender.io 的指南:
git clone https://github.com/prerender/prerender.git
cd prerender
npm install
node server.js
然后试图去:
http://localhost:3000/http://localhost:4000/test
我得到的 returned html 是:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Documents SSR</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="stylesheet" href="styles.3ff695c00d717f2d2a11.css">
<style></style>
</head>
<body>
<app-root _nghost-sc0="" ng-version="8.2.3" _nghost-serverapp-c0="">
<router-outlet _ngcontent-serverapp-c0=""></router-outlet>
<component1>
<!---->
<component2></component2>
</component1>
</app-root>
</body>
</html>
我希望 Prerender.io 渲染 component2
内的所有内容,但如您所见,我什么也没得到。
我是不是在某处缺少配置或者 Prerender.io 不支持 Angular?
如果我直接转到 http://localhost:4000/test
,我会得到完整的渲染图 HTML。
编辑
看起来 Prerender.io 没有等待我的最后一个 ajax 调用完成才渲染?
发现问题 - 不要使用 ShadowDom。
我的 component2
正在使用 encapsulation: ViewEncapsulation.ShadowDom
。
删除让 Prerender 给我整个 HTML.