简体   繁体   English

聚合物1.0 <template> 标签不起作用

[英]Polymer 1.0 <template> tag not working

I lifted the most basic example from the docs , and it seems that the <template> tag is not working. 我从docs中提出了最基本的示例,看来<template>标记不起作用。 Nothing is rendered within the <register-me> tag mounted in the document: 安装在文档中的<register-me>标记内未呈现任何内容:

已安装的注册我的检查员视图

Expected: "Hello from my local DOM" 预期:“来自我本地DOM的问候”

  <!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> 

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

You are using Polymer Micro, which does not include template stamping. 您正在使用Polymer Micro,它不包括模板冲压。 It is included in Polymer Mini, however ( docs ). 但是,它包含在Polymer Mini中( docs )。

Edit 编辑

If you want to define elements in your main document, you need to listen to the HTMLImports.whenReady event. 如果要在主文档中定义元素,则需要侦听HTMLImports.whenReady事件。 Otherwise, it will not work in some browsers. 否则,它将无法在某些浏览器中使用。 This is explained here . 在这里解释。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM