首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >聚合物0.8抛偏

聚合物0.8抛偏
EN

Stack Overflow用户
提问于 2015-04-12 09:43:52
回答 1查看 99关注 0票数 0

我试过聚合物教程,这是很好的聚合物0.5.4,而不是与聚合物0.8工作

index.html

代码语言:javascript
运行
复制
<!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

代码语言:javascript
运行
复制
<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,它就能工作。你知道为什么这不管用吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-12 10:08:58

许多事情已经从聚合物0.5转变为聚合物0.8,几乎所有在0.5中存在的apis都不能用于0.8。

重写源代码的最好方法是:

index.html不需要改变

但是Postcar.html需要重做一次:

代码语言:javascript
运行
复制
<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://www.polymer-project.org/0.8/docs/migration.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29588051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档