nim*_*rod 6 web-component angular-cli angular angular6 angular-elements
我刚刚使用Angular 6创建了我的第一个Web组件.一切正常,直到我尝试将Web组件集成到现有应用程序中:
集成了Web组件的应用程序(https://www.example.com):
<script type="text/javascript" src="https://component.example.com/html-imports.min.js"></script>
<link rel="import" href="https://component.example.com/element.html">
<my-web-component uuid="2342-asdf-2342-ffsk"></my-web-component>
Run Code Online (Sandbox Code Playgroud)
我的Web组件index.html不包含base-href.
浏览器现在尝试加载Web组件的资源:
https://www.example.com/assets/i18n/de_CH.json
Run Code Online (Sandbox Code Playgroud)
代替
https://component.example.com/assets/i18n/de_CH.json
Run Code Online (Sandbox Code Playgroud)
当我尝试在构建期间添加base-href时,会导致:
ng build --configuration=development --base-href https://component.example.com/
Cannot read property 'startTag' of null
TypeError: Cannot read property 'startTag' of null
at IndexHtmlWebpackPlugin.<anonymous> (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:147:62)
at Generator.next (<anonymous>)
at fulfilled (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:4:58)
Run Code Online (Sandbox Code Playgroud)
任何帮助都非常感谢,我的想法已经不多了.
首先提示一些:
<base>已经存在的<head>因为它们都共享相同的起始URL.此外,在这种情况下使用相对URL和绝对URL都没有意义.--base-href配置甚至可以覆盖HTML中的配置,所以不用担心.typein script标签,它绝对不是Javascript,也没有必要.最后看:
<base href="https://component.example.com/">
<script src="html-imports.min.js"></script>
<link rel="import" href="element.html">
<my-web-component uuid="2342-asdf-2342-ffsk"></my-web-component>
Run Code Online (Sandbox Code Playgroud)回到问题,你能给我一个组件源代码的小提琴吗?问题可能在于您在组件内部加载文件的方式,而不是导入组件的方式,也不在于此处的代码.
| 归档时间: |
|
| 查看次数: |
1730 次 |
| 最近记录: |