2017-05-05 56 views
0

我試圖啓用Firefox的Polymer Web組件,以便我可以瀏覽Firefox上的Polymer網頁。使用Webjars的Windows上的聚合物Web組件和Mozilla Firefox

我試過這些說明,但沒有任何改變,它似乎像Firefox完全忽略我的組件。

https://www.designedbyaturtle.co.uk/2015/how-to-enable-web-components-in-firefox-shadow-dom/

我還導入webcomponents.js polyfills在我index.html

所以,我所做的就是以下幾點:

我已經寫了下面的Web組件test-firefox.html目錄elements

<dom-module name="test-firefox"> 
    <template> 
    <h2>Firefox says hi too!</h2> 
    </template> 
    <script> 
    Polymer({ 
     is: 'test-firefox' 
    }); 
    </script> 
</dom-module> 

,這是我index.html文件:

<!doctype html> 
<html> 
    <head> 
     <link rel="import" href="webjars/polymer/1.6.1/polymer.html"> 
     <script src="webjars/webcomponentsjs/0.7.22/webcomponents.js"></script> 
     <script src="webjars/webcomponentsjs/0.7.22/webcomponents-lite.min.js"></script> 

     <link rel="import" href="elements/test-firefox.html"> 

    </head> 
    <body> 
    <h1>Hello Firefox!</h1> 
    <test-firefox></test-firefox> 
    </body> 
</html>` 

正如您所看到的,而不是bower_components,我正在使用相應的webjars(對於Polymerwebcomponents.js,webcomponents-lite.min.js)。我已經添加了我的pom.xml中的依賴關係,並且它們通常都已安裝。

那麼我注意到發生的情況是很奇怪:

  • 對於谷歌Chrome,一切工作完全正常。
  • 對於Linux上的Mozilla Firefox,相同。
  • 對於Win10上的Mozilla Firefox,Web組件不會呈現,它就像瀏覽器完全忽略它。

任何想法?

回答

0

你能改寫你的問題嗎?

你不需要啓用任何東西來獲得在Firefox中工作的網站(當然,你可以訪問https://www.polymer-project.org/,它適用於你)。

如果Firefox「忽略」你的組件,也許你缺少這些元素的導入。

檢查此頁https://www.polymer-project.org/1.0/docs/devguide/registering-elements並查看如何使用<link rel="import" href="bower_components/polymer/polymer.html">。您還需要以這種方式導入自己的組件,以便他們工作。

+0

謝謝你的回答。我重寫了上面的問題,以便提供更多信息。我之前沒有提到的,重要的是我使用的是webjars。如果你有任何經驗/想法,我會很感激閱讀。 – luthien

+0

對不起,我沒有使用webjars的經驗。 一般而言,您的代碼看起來不錯 - 但您應該只使用「webcomponents-lite.min.js」 - 並且請從該文章中刪除webcomponents的內部firefox標誌 - 它可能會破壞代碼中的某些內容。 也請查看您的瀏覽器控制檯 - 看看你是否沒有得到一些不正確的導入路徑和404的。 – Ergo