我刚刚用Range6创建了我的第一个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>
我的web组件index.html不包含基-href。
浏览器现在尝试加载web组件的资产:
https://www.example.com/assets/i18n/de_CH.json
相反,
https://component.example.com/assets/i18n/de_CH.json
当我试图在构建过程中添加基-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)
任何帮助都是非常感谢的,我的想法快用完了。
发布于 2018-07-10 10:27:36
先给几个提示:
<base>
中的<head>
,因为它们都共享相同的起始URL。而且,在这种情况下使用相对URL和绝对URL是没有意义的。--base-href
配置甚至可以覆盖HTML中的配置,所以不要担心。type
标签中定义script
,它肯定不是Javascript,也没有必要。回到问题上,你能告诉我你的组件源代码吗?问题可能在于您在组件中加载文件的方式,而不是导入组件的方式,也不是这里的代码。
发布于 2018-07-12 07:21:50
发布于 2018-07-16 11:56:18
上述任何一个答案对我来说都是正确的,所以我在贴出解决问题的方法。我完全停止使用基地-href了。对于所有资产,我使用其他方式加载它们:
我希望这能帮到你。
https://stackoverflow.com/questions/51216624
复制相似问题