1

是我一个人还是上次发布的聚合物修剪了小胡子?我发誓这个代码片段(http://jsbin.com/eRimiJo/10/edit)上周完美运行,现在它没用了,因为小胡子魔法似乎不再起作用了:

<script src="http://www.polymer-project.org/polymer.min.js"></script>

<polymer-element name="test-attr" attributes="width" noscript>
<template>
    <style>
        @host {
            :scope {
              display: block;
              width: {{width}}px;
              height: 100px;
              background-color: black;
              }
            }
        </style>
    <content></content>
    </template>
</polymer-element>

<test-attr width="100">Hello</test-attr>

编辑:编辑以删除明显的错别字

4

1 回答 1

2

您的示例中有几件事需要更改:

  • <content>需要在外部</template>
  • 您将绑定100px为宽度属性值。删除“px”,否则绑定输出将width: 100pxpx;变为<style>.

随着变化:http: //jsbin.com/ODEGika/3/edit

也就是说,这仅在 Chrome Canary 中对我有用。它看起来像 polyfill 的回归。在此处归档:https ://github.com/Polymer/polymer/issues/270

于 2013-09-09T16:57:06.340 回答