Yeoman聚合物用于聚合物0.8

时间:2015-03-09 20:23:04

标签: javascript polymer web-component

我正在使用Yeoman来支撑我的Polymer项目。我将Polymer和其他所有内容升级到0.8预览版,应用程序停止工作。

我应该对应用程序进行哪些更改才能使0.8预览正常工作?

3 个答案:

答案 0 :(得分:4)

以下是关于从聚合物0.5到0.8的转换过程的说明。

请参阅Polymer 0.8迁移指南

https://www.polymer-project.org/0.8/docs/migration.html

HTML转换过程

  1. 聚合物元素到dom-module
  2. 聚合物元素名称
  3. polymer-element属性/属性camelCase到dash-case
  4. 聚合物元素属性=" xxx xxxx"添加到javascript属性
  5. 聚合物元素布局<polymer-element name="x-foo" layout horizontal wrap>
    • <link rel="import" href="../layout/layout.html">添加到其他导入的顶部
    • 将hostAttributes hostAttributes: {class: "layout horizontal wrap"}添加到Polymer({
  6. polymer-element从<link rel="import" type="css" href="my-awesome-button.css">
  7. 向上移动<template> to <dom-module>
  8. polymer-element从<style></style><template>移动<dom-module>
    • 请参阅www.polymer-project.org/0.8/docs/devguide/local-dom.html
  9. 模板重复到=&#34; x-repeat&#34;并重复=到项目=(临时)
    • 请参阅www.polymer-project.org/0.8/docs/devguide/experimental.html
  10. 模板是=&#34;自动绑定&#34; to is =&#34; x-binding&#34; (临时)
  11. 模板if = to is =&#34; x-if&#34; (临时的)或使用diplay block或none
  12. <div>First: {{first}}</div><span>{{first}}</span><br>
  13. 的textContent绑定
  14. 元素on-click="{{handleClick}}"on-click="handleClick"
  15. Javascript转换过程

    1. 聚合物元素名称为Polymer({is:
    2. 聚合物元素属性=&#34;&#34;到javascript properties: { }
    3. CSS转换过程

      1. 聚合物元素从<style></style><template>移动<dom-module>(如上所述)
        • 请参阅www.polymer-project.org/0.8/docs/migration.html#styling
      2. Polymer团队的纸张按钮转换的差异示例

        http://chuckh.github.io/road-to-polymer/compare-code.html?el=paper-button

答案 1 :(得分:0)

在0.5和0.8之间有一个很好的写作 - 可能有助于:https://divshot.com/blog/web-components/polymer-0-8-sneak-peek/

答案 2 :(得分:0)

首先,如果没有仔细检查更改日志,则不应将第三方代码升级到预览版本。一般

在声称是0.8 - 候选发布版的1.0中,实际上已经改变了everything。例如。 polymer-element支持dom-module。等

您的问题的答案是:除非您真的想从头开始重新编写代码,否则应该回滚到0.5。