Polymer 1.0 <template>标签不起作用

时间:2015-08-09 19:08:32

标签: polymer polymer-1.0

我解除了docs中最基本的示例,似乎<template>标记无效。在文档中安装的<register-me>标记内没有任何内容:

inspector view of mounted register-me

预期:&#34;您好,来自我当地的DOM&#34;

&#13;
&#13;
    <!DOCTYPE html>
    <html>
    <head>
      <title>Polymer 1.0.6 test</title>
      <script src="https://rawgit.com/webcomponents/webcomponentsjs/v0.7.10/webcomponents-lite.min.js"></script>
      <link rel="import" href="https://rawgit.com/Polymer/polymer/v1.0.6/polymer-mini.html">
    </head>
    <body>
      
    <dom-module id="register-me">
      <template>
        <div>Hello from my local DOM</div>
      </template>
      <script>
        Polymer({is: "register-me"});
      </script>
    </dom-module>
      
    <register-me></register-me>

    </body>
    </html>
&#13;
&#13;
&#13;

直播:http://jsbin.com/qijegu/edit?html,output

1 个答案:

答案 0 :(得分:4)

您使用的是Polymer Micro,它不包含模板印章。它包含在Polymer Mini中,但是(docs)。

修改

如果要在主文档中定义元素,则需要侦听HTMLImports.whenReady事件。否则,它将无法在某些浏览器中使用。这解释为here

HTMLImports.whenReady(function () {
     Polymer({is: "register-me"});
});