美文网首页
3-1 Feature overview 功能概述

3-1 Feature overview 功能概述

作者: 1bdd9a4a74a2 | 来源:发表于2015-12-16 23:38 被阅读58次

    layout: default
    type: guide
    shortname: Docs
    title: Feature overview
    subtitle: Developer guide

    The Polymer library provides a set of features for creating custom elements. These features are designed to make it easier and faster to make custom elements that work like standard DOM elements. Similar to standard DOM elements, Polymer elements can be:
    Polymer库为您提供了一套功能来创建自定义标签。这些功能设计能够简单、迅速地让自定义标签象标准DOM标签一样使用。类似标准DOM标签,Polymer标签能够:

    • Instantiated using a constructor or document.createElement.
    • Configured using attributes or properties.
    • Populated with internal DOM inside each instance.
    • Responsive to property and attribute changes (for example, by populating data into the DOM, or firing an event).
    • Styled with internal defaults or externally.
    • Responsive to methods that manipulate its internal state.
    • 使用构造函数或者document.createElement实例化;
    • 配置使用特征或属性;
    • 位于每个实例的内部DOM;
    • 响应属性和特征的变化(例如,填充数据到DOM,或者触发事件);
    • 内部默认样式或外部样式;
    • 响应方法操作内部状态;

    A basic {{site.project_title}} element definition looks like this:
    基本{{site.project_title}}标签定义看上去像这样:

    <dom-module id="element-name">
    
      <template>
        <style>
          /* CSS rules for your element  你标签的CSS规则 */
        </style>
      
        <!-- local DOM for your element 你标签的局部DOM-->
    
        <div>{%raw%}{{greeting}}{%endraw%}</div> <!-- data bindings in local DOM 在局部DOM内的数据绑定-->
      </template>
    
      <script>
        // element registration 注册标签
        Polymer({
          is: "element-name",
    
          // add properties and methods on the element's prototype
          // 在标签原型上添加属性和方法
    
          properties: {
            // declare properties for the element's public API
            // 为标签的公共API声明属性
            greeting: {
              type: String,
              value: "Hello!"
            }
          }
        });
      </script>
    
    </dom-module>
    

    This guide divides the features into the following groups:
    这个指南将划分为以下几组功能:

    • Registration and lifecycle. Registering an element associates a class (prototype) with a custom element name. The element provides callbacks to manage its lifecycle. Use behaviors to share code.
    • 注册和生命周期。通过一个自定义标签名注册一个标签并关联一个Class(原型)。标签提供回调函数管理它的生命周期。通过行为共享代码。
    • Declared properties. Declared properties can be configured from markup using attributes. Declared properties can optionally support change observers, two-way data binding, and reflection to attributes.You can also declare computed properties and read-only properties.
    • 声明属性。属性声明可以从标记上使用特征来配置。属性声明支持随意改变观测者,双向数据绑定,和反射到特征。你还可以声明计算属性和只读属性。
    • Local DOM. Local DOM is the DOM created and managed by the element.
    • 局部DOM。局部DOM是通过标签创建和管理的DOM
    • Events. Attaching event listeners to the host object
      and local DOM children. Event retargeting.
    • 事件。附加事件监听器到主机对象和局部DOM。事件重定向。
    • Data binding. Property bindings. Binding to attributes.
    • 事件绑定。属性绑定。绑定到特征。
    • Behaviors. Behaviors are reusable modules of code that can be mixed into {{site.project_title}} elements.
    • 行为。行为是能够混合到{{site.project_title}}标签里的可重用的代码模块。
    • Utility functions. Helper methods for common tasks.
    • 公用函数。为共同任务的帮助方法。
    • Experimental features and elements. Experimental template and styling features. Feature layering.
    • 实验功能和标签。实验模板和样式功能。功能层。

    If you're migrating an existing 0.5 element to the new APIs, see the Migration guide for advice.
    如果你从 0.5版迁移到新APIs,参看迁移指南

    If you're upgrading from the 0.8 release, see the Release notes.
    如果你从0.8版升级,参考版本说明

    相关文章

      网友评论

          本文标题:3-1 Feature overview 功能概述

          本文链接:https://www.haomeiwen.com/subject/qrqphttx.html