使用Webjars的Windows上的聚合物Web组件和Mozilla Firefox
我试图启用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
(对于Polymer
,webcomponents.js
,webcomponents-lite.min.js
)。我已经添加了我的pom.xml
中的依赖关系,并且它们通常都已安装。
那么我注意到发生的情况是很奇怪:
- 对于谷歌Chrome,一切工作完全正常。
- 对于Linux上的Mozilla Firefox,相同。
- 对于Win10上的Mozilla Firefox,Web组件不会呈现,它就像浏览器完全忽略它。
任何想法?
你能改写你的问题吗?
你不需要启用任何东西来获得在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">
。您还需要以这种方式导入自己的组件,以便他们工作。
谢谢你的回答。我重写了上面的问题,以便提供更多信息。我之前没有提到的,重要的是我使用的是webjars。如果你有任何经验/想法,我会很感激阅读。 – luthien
对不起,我没有使用webjars的经验。 一般而言,您的代码看起来不错 - 但您应该只使用“webcomponents-lite.min.js” - 并且请从该文章中删除webcomponents的内部firefox标志 - 它可能会破坏代码中的某些内容。 也请查看您的浏览器控制台 - 看看你是否没有得到一些不正确的导入路径和404的。 – Ergo