2016-10-27 40 views
5

için bir değer sağlayın Bir Chrome Tarayıcı İşlem Uzantısı yapıyorum.Chrome Uzantısı - Temel href ayarlanmamış. Lütfen APP_BASE_HREF

Angular 2 uygulamasını Chrome'daki Popup Penceresine yüklemeye çalışıyorum.

Bunu Angular 1.5'i kullanmadan önce yaptım, ancak Angular 2'yi kullanmaya ve hata almaya çalıştım.

Unhandled Promise rejection: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document. ; Zone: ; Task: Promise.then ; Value: Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.(…) Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.

benim popu.html içine <base href="/"> etiketi koydu. Ancak sorun, vendor.js ve main.js'nin Chrome tarafından yüklenmesini (ve popup.html tarafından yüklenmeden önce) ve böylece <base href="/">

'un nasıl çözüleceğini merak ettiğim bir HTML sayfası olmamasıdır. konu.

Popup.html

enter image description here

<!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> 
+1

baz href ayarlayabilirsiniz. Şu anda açık sekme için konsolu gösteriyorsunuz, açılır pencerede değil. Bu nedenle, gördüğünüz hatalar bir içerik komut dosyasından gelir. Açılır pencerede neler olduğunu görmek için tarayıcı eyleminin içerik menüsünden "Pop-up'ı denetle" yi uyarmalısınız. – Xan

+0

Teşekkürler Xan, sağınızda, pop-up ve içerik senaryosu etrafında bir yanlış anlaşılma vardı ve bu yüzden çok fazla sorun yaşadım ve APP_BASE_HREF sorunu –

cevap

19

Sen kod yerine anlamıyorum

import { APP_BASE_HREF } from '@angular/common'; 

@NgModule({ 
    providers: [ 
    { provide: APP_BASE_HREF, useValue: '/' } 
    ] 
}) 
class AppModule {} 
+0

çok ötesinde bir çok sorun vardı! – commonSenseCode

İlgili konular