主页中元素未在IE

时间:2015-07-09 11:07:26

标签: polymer

为什么这适用于Chrome,但不适用于IE:

<!doctype html>
<html>
<head>
    <script src='bower_components/webcomponentsjs/webcomponents.min.js'></script>
    <link rel='import' href='base-element.html'>
</head>
<body>
    <base-element></base-element>
</body>
</html>

在base-element

中使用它
<link rel="import" href="bower_components/polymer/polymer.html">
<dom-module id="base-element">
    <template>
        <div>test</div>
    </template>
</dom-module>
<script>
    Polymer({
        is: 'base-element'
    });
</script>

如果不是

<!doctype html>
<html>
<head>
    <script src='bower_components/webcomponentsjs/webcomponents.min.js'></script>
    <link rel="import" href="bower_components/polymer/polymer.html">
</head>
<body>
    <dom-module id="base-element">
        <template>
            <div>test</div>
        </template>
    </dom-module>
    <script>
        Polymer({
            is: 'base-element'
        });
    </script>
    <base-element></base-element>
</body>

它适用于Chrome,但不适用于IE

干杯

Stack Overflow认为我在这篇文章中有太多“代码”...所以请跳过这个废话:“Lorem ipsum dolor sit amet,consectetur adipiscing elit.Quisque eu erat vel nunc lacinia commodo a sed nisl.Quisque commodo turpis sed diam fringilla cursus.Nunc nisi mi,lacinia maximus lacus in,elementum vehicula purus.Hospendisse ut dolor nisi.Nunc porttitor sem quis viverra molestie.Cras porta in risus tempor molestie。Fusce at magna tellus“

1 个答案:

答案 0 :(得分:1)

这似乎有效:

<!doctype html>
<html>
<head>
    <script src='bower_components/webcomponentsjs/webcomponents.min.js'></script>
    <link rel="import" href="bower_components/polymer/polymer.html">
</head>
<body>
    <dom-module id="base-element">
        <template>
            <div>test</div>
        </template>
    </dom-module>
    <script>
        HTMLImports.whenReady(function() { Polymer({
            is: 'base-element'
        });});
    </script>
    <base-element></base-element>
</body>

它的HTMLImport可以解决这个问题....但我不知道为什么。任何人? : - )