将 Web 组件与 Scully 一起使用?
Using web components with Scully?
我构建了一个加载动态内容并通过 Scully 呈现的应用程序。内容中包含这样的 Web 组件:
Content selection dialog that looks like this:
<fs-image url='https://fireflysemantics.github.io/i/developer/instant-html-vscode.png'></fs-image></p>
<p>Sample topic examples</p>",
我猜测 Scully 试图寻找与标签 fs-image
匹配的 Angular 组件,但由于没有找到,它只是删除了 fs-image
元素来自生成的内容。
我们如何告诉 Scully fs-image
是一个网络组件?
要将自定义元素与 Angular 一起使用,我们需要添加自定义架构:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
...
schemas: [CUSTOM_ELEMENTS_SCHEMA],
所以我添加了,但是内容 fs-image
网络组件仍然从 Scully 生成的内容中剥离。
创建了 Scully 问题
Scully 不会从生成的应用程序中删除任何内容,除非您使用插件主动删除它。
当您 运行 您的应用程序时,这是它生成的输出:
<html lang="en"><head>
<meta charset="utf-8">
<title>Test</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.09e2c710755c8867a460.css"><style></style></head>
<body data-new-gr-c-s-check-loaded="14.991.0" data-gr-ext-installed="">
<app-root _nghost-aoj-c3="" ng-version="11.0.9">
<router-outlet _ngcontent-aoj-c3=""></router-outlet>
<app-home _nghost-aoj-c2="">
<p _ngcontent-aoj-c2="">
<h1> Scully Custom Element Test</h1>
</p>
</app-home><!---->
</app-root>
<script src="runtime.0e49e2b53282f40c8925.js" defer=""></script>
<script src="polyfills.1f3b39c11fffb306d5a3.js" defer=""></script>
<script src="main.30df6ebad07b05698939.js" defer=""></script>
</body></html>
您可以清楚地看到 fs-image
元素无处可寻。
Scully 无法呈现任何不在应用程序输出中的内容。
您可以通过以下方式自行检查:
ng build --prod
npx scully serve
然后打开http://localhost:1864/
。
当您这样做时,您正在查看未修改的应用程序。这就是 Scully 用来生成输出的内容。
如果它不在那里,Scully 无法知道它。
我构建了一个加载动态内容并通过 Scully 呈现的应用程序。内容中包含这样的 Web 组件:
Content selection dialog that looks like this:
<fs-image url='https://fireflysemantics.github.io/i/developer/instant-html-vscode.png'></fs-image></p>
<p>Sample topic examples</p>",
我猜测 Scully 试图寻找与标签 fs-image
匹配的 Angular 组件,但由于没有找到,它只是删除了 fs-image
元素来自生成的内容。
我们如何告诉 Scully fs-image
是一个网络组件?
要将自定义元素与 Angular 一起使用,我们需要添加自定义架构:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
...
schemas: [CUSTOM_ELEMENTS_SCHEMA],
所以我添加了,但是内容 fs-image
网络组件仍然从 Scully 生成的内容中剥离。
创建了 Scully 问题
Scully 不会从生成的应用程序中删除任何内容,除非您使用插件主动删除它。
当您 运行 您的应用程序时,这是它生成的输出:
<html lang="en"><head>
<meta charset="utf-8">
<title>Test</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.09e2c710755c8867a460.css"><style></style></head>
<body data-new-gr-c-s-check-loaded="14.991.0" data-gr-ext-installed="">
<app-root _nghost-aoj-c3="" ng-version="11.0.9">
<router-outlet _ngcontent-aoj-c3=""></router-outlet>
<app-home _nghost-aoj-c2="">
<p _ngcontent-aoj-c2="">
<h1> Scully Custom Element Test</h1>
</p>
</app-home><!---->
</app-root>
<script src="runtime.0e49e2b53282f40c8925.js" defer=""></script>
<script src="polyfills.1f3b39c11fffb306d5a3.js" defer=""></script>
<script src="main.30df6ebad07b05698939.js" defer=""></script>
</body></html>
您可以清楚地看到 fs-image
元素无处可寻。
Scully 无法呈现任何不在应用程序输出中的内容。
您可以通过以下方式自行检查:
ng build --prod
npx scully serve
然后打开http://localhost:1864/
。
当您这样做时,您正在查看未修改的应用程序。这就是 Scully 用来生成输出的内容。
如果它不在那里,Scully 无法知道它。