Dav*_*wys 7 javascript google-chrome-extension angular
我正在构建Chrome浏览器操作扩展.
我正在尝试将Angular 2应用程序加载到Chrome中的弹出窗口中.
我在使用Angular 1.5之前已经这样做了,但尝试使用Angular 2并收到错误.
未处理的承诺拒绝:没有基本的href设置.请提供APP_BASE_HREF标记的值或向文档添加基本元素.; 区域:; 任务:Promise.then; 值:错误:没有设置基本href.请提供APP_BASE_HREF标记的值或向文档添加基本元素.(...)错误:没有设置基本href.请提供APP_BASE_HREF标记的值或向文档添加基本元素.
我把<base href="/">
标签放到我的popu.html中.但问题是,vendor.js和main.js被Chrome下载(并且在被popup.html加载之前),所以没有HTML页面放在哪里<base href="/">
只是想知道如何解决这个问题.
Popup.html
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<title>FountainJS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="icon" type="image/png" href="http://fountainjs.io/assets/imgs/fountain.png"/>
<link href="../styles/popup.css" rel="stylesheet">
</head>
<body>
<div style="width: 200px; height: 150px;">
<fountain-root>My Awesome Chrome Popup should load with Angular 2 right Here</fountain-root>
<script type="text/javascript" src="../scripts/vendor.js"></script>
<script type="text/javascript" src="../scripts/main.js"></script>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Pau*_*tha 20
您可以在代码中设置基本href
import { APP_BASE_HREF } from '@angular/common';
@NgModule({
providers: [
{ provide: APP_BASE_HREF, useValue: '/' }
]
})
class AppModule {}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6971 次 |
最近记录: |