Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 聚合物就绪可以在IE11上启动,但不能在Firefox或Chrome上启动_Javascript_Import_Polymer - Fatal编程技术网

Javascript 聚合物就绪可以在IE11上启动,但不能在Firefox或Chrome上启动

Javascript 聚合物就绪可以在IE11上启动,但不能在Firefox或Chrome上启动,javascript,import,polymer,Javascript,Import,Polymer,我遇到了一个意想不到的问题 我有两页是关于聚合物的。两者在IE11上都可以正常工作,没有任何问题(除了性能缓慢)。 现在,在Firefox和Chrome上,其中一个不工作,从来没有准备好,另一个工作很好。 如果有的话,人们会认为IE是有麻烦的人 与这种非燃烧行为相关,本页在FF或Chrome上显示的唯一聚合物元素是主工具栏,以及其中的内容,仅此而已。 我只是不知道下一步该怎么做 以下是标题。第一个是来自页面,它在任何地方都有效,没有问题 <!DOCTYPE html PUBLIC "-//

我遇到了一个意想不到的问题

我有两页是关于聚合物的。两者在IE11上都可以正常工作,没有任何问题(除了性能缓慢)。 现在,在Firefox和Chrome上,其中一个不工作,从来没有准备好,另一个工作很好。 如果有的话,人们会认为IE是有麻烦的人

与这种非燃烧行为相关,本页在FF或Chrome上显示的唯一聚合物元素是主工具栏,以及其中的内容,仅此而已。 我只是不知道下一步该怎么做

以下是标题。第一个是来自页面,它在任何地方都有效,没有问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
    <title>N-Adviser</title>
    [... a bunch of element imports ...]
    <script src="components/webcomponentsjs/webcomponents.js"></script>
    <style shim-shadowdom>
        [...some styling...]
    </style>
    <script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
</head>

N-顾问
[…一堆元素导入…]
[…一些样式…]
这是坏消息

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="headPortal" runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
    <title>Portal</title>
    <link rel="import" href="components/font-roboto/roboto.html" />
    <link rel="import" href="components/polymer/polymer.html" />
    [...a bunch of element imports...]
    <link type="text/css" rel="stylesheet" href="Styles/LoginStyle.css" shim-shadowdom />
    <script src="components/webcomponentsjs/webcomponents.js"></script>
    <style></style>
    <script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
</head>

门户
[…一堆元素导入…]
除了其中一个从外部文件导入CSS这一事实之外,看不到任何差异,这应该无关紧要

在所有html之后,它们都有自己的javascript代码

<script type="text/javascript">
    $(document).ready(function () {
        alert("docready");
    });
    window.addEventListener('polymer-ready', function (e) {
        alert("polready");
    [...]
</script>

$(文档).ready(函数(){
警报(“docready”);
});
window.addEventListener('polymer-ready',函数(e){
警报(“polready”);
[...]

两个都启动
document.ready
,但只有第一个启动polymer ready。有什么想法吗?

应该在html导入之前加载webcomponents.js。尝试将该脚本标记移到所有导入之前(另请参阅)。应该就这样了

我想我可以解释这种奇怪的行为。可能在导入文件的第一个示例中没有聚合物特定的功能,而在第二个示例中有(请注意,Polymer!=web components.webcomponents.js包含聚合物特定的功能)。由于IE11本机不支持web组件,因此它跳过了html导入标记(它不知道它们)然后聚合物的polyfill在加载webcomponents.js后扫描文档并加载它们(因为这是polyfill中的一个函数)


因为Chrome和FF确实支持web组件,所以他们在webcomponents.js和Polymer函数尚未加载之前“看到”html导入。因此它不起作用。

我以为我已经对导入的每个订单进行了测试,但再次尝试更改webcomponents.js。仍然不起作用,Polymer ready未启动:/而且,我没有请回答我的问题,但正在运行的页面比另一个页面复杂得多,并且导入了“坏”页面所做的所有事情,以及许多其他内容。我会记住你的解释,因为它可能有用,但在这种情况下不会。对不起,我的意思是,你的解释很有道理,仍然无法解决问题