我试过聚合物教程,这是很好的聚合物0.5.4,而不是与聚合物0.8工作
index.html
<!doctype html>
<html>
 <head>
  <script src="bower_components/webcomponentsjs/webcomponents.js"></script>
  <link rel="import" href="post-card.html">
  <style>
   html,body {
    height: 100%;
    margin: 0;
    background-color: #E5E5E5;
   }
  </style>
 </head>
 <body unresolved>
      <post-card>
        <img width="70" height="70"
          src="../images/avatar-07.svg">
        <h2>Another Developer</h2>
        <p>I'm composing with shadow DOM!</p>
      </post-card>
 </body>
</html>和post.post
<link rel="import" href="bower_components/polymer/polymer.html">
<polymer-element name="post-card">
  <template>
    <style>
    :host {
      display: block;
      position: relative;
      background-color: white;
      padding: 20px;
      width: 100%;
      font-size: 1.2rem;
      font-weight: 300;
    }
    .card-header {
      margin-bottom: 10px;
    }
    polyfill-next-selector { content: '.card-header h2'; }
    .card-header ::content h2 {
      margin: 0;
      font-size: 1.8rem;
      font-weight: 300;
    }
    polyfill-next-selector { content: '.card-header img'; }
    .card-header ::content img {
      width: 70px;
      border-radius: 50%;
      margin: 10px;
    }
    </style>
    <!-- CARD CONTENTS GO HERE -->
    <div class="card-header" layout horizontal center>
      <content select="img"></content>
      <content select="h2"></content>
    </div>
    <content></content>
  </template>
  <script>
  Polymer({});
  </script>
</polymer-element>在bower.json中,如果我使用0.8.0到0.5.4,它就能工作。你知道为什么这不管用吗?
发布于 2015-04-12 10:08:58
许多事情已经从聚合物0.5转变为聚合物0.8,几乎所有在0.5中存在的apis都不能用于0.8。
重写源代码的最好方法是:
index.html不需要改变
但是Postcar.html需要重做一次:
<dom-module id="post-card">
  <style>
    :host {
      display: block;
      position: relative;
      background-color: white;
      padding: 20px;
      width: 100%;
      font-size: 1.2rem;
      font-weight: 300;
    }
    .card-header {
      margin-bottom: 10px;
    }
    polyfill-next-selector { content: '.card-header h2'; }
    .card-header ::content h2 {
      margin: 0;
      font-size: 1.8rem;
      font-weight: 300;
    }
    polyfill-next-selector { content: '.card-header img'; }
    .card-header ::content img {
      width: 70px;
      border-radius: 50%;
      margin: 10px;
    }
    </style>
  <template>
    <div class="card-header" layout horizontal center>
      <content select="img"></content>
      <content select="h2"></content>
    </div>
  </template>
</dom-module>
<script>
  Polymer({is: "post-card"});
</script>聚合物的α释放发生了很大变化:
提到聚合物0.8的所有变化是不可行的,因为它一直在变化。
有关聚合物0.8的更多信息,请参考谷歌的这份文档:
https://stackoverflow.com/questions/29588051
复制相似问题