3-1 Feature overview 功能概述

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庫為您提供了一套功能來創(chuàng)建自定義標簽骂蓖。這些功能設(shè)計能夠簡單征讲、迅速地讓自定義標簽象標準DOM標簽一樣使用。類似標準DOM標簽,Polymer標簽?zāi)軌颍?/p>

  • 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.
  • 使用構(gòu)造函數(shù)或者document.createElement實例化锥债;
  • 配置使用特征或?qū)傩裕?/li>
  • 位于每個實例的內(nèi)部DOM;
  • 響應(yīng)屬性和特征的變化(例如,填充數(shù)據(jù)到DOM锁荔,或者觸發(fā)事件)瞎领;
  • 內(nèi)部默認樣式或外部樣式;
  • 響應(yīng)方法操作內(nèi)部狀態(tài)勇劣;

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規(guī)則 */
    </style>
  
    <!-- local DOM for your element 你標簽的局部DOM-->

    <div>{%raw%}{{greeting}}{%endraw%}</div> <!-- data bindings in local DOM 在局部DOM內(nèi)的數(shù)據(jù)綁定-->
  </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.
  • 注冊和生命周期靖避。通過一個自定義標簽名注冊一個標簽并關(guān)聯(lián)一個Class(原型)。標簽提供回調(diào)函數(shù)管理它的生命周期比默。通過行為共享代碼幻捏。
  • 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.
  • 聲明屬性。屬性聲明可以從標記上使用特征來配置命咐。屬性聲明支持隨意改變觀測者篡九,雙向數(shù)據(jù)綁定,和反射到特征醋奠。你還可以聲明計算屬性和只讀屬性榛臼。
  • Local DOM. Local DOM is the DOM created and managed by the element.
  • 局部DOM。局部DOM是通過標簽創(chuàng)建和管理的DOM
  • Events. Attaching event listeners to the host object
    and local DOM children. Event retargeting.
  • 事件窜司。附加事件監(jiān)聽器到主機對象和局部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.
  • 公用函數(shù)漠秋。為共同任務(wù)的幫助方法。
  • Experimental features and elements. Experimental template and styling features. Feature layering.
  • 實驗功能和標簽抵屿。實驗?zāi)0搴蜆邮焦δ芮旖酢9δ軐印?/li>

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版升級轧葛,參考版本說明搂抒。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市尿扯,隨后出現(xiàn)的幾起案子求晶,更是在濱河造成了極大的恐慌,老刑警劉巖衷笋,帶你破解...
    沈念sama閱讀 219,539評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件芳杏,死亡現(xiàn)場離奇詭異,居然都是意外死亡辟宗,警方通過查閱死者的電腦和手機爵赵,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,594評論 3 396
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來泊脐,“玉大人空幻,你說我怎么就攤上這事∪菘停” “怎么了秕铛?”我有些...
    開封第一講書人閱讀 165,871評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長缩挑。 經(jīng)常有香客問我如捅,道長,這世上最難降的妖魔是什么调煎? 我笑而不...
    開封第一講書人閱讀 58,963評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮己肮,結(jié)果婚禮上士袄,老公的妹妹穿的比我還像新娘。我一直安慰自己谎僻,他們只是感情好娄柳,可當(dāng)我...
    茶點故事閱讀 67,984評論 6 393
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著艘绍,像睡著了一般赤拒。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,763評論 1 307
  • 那天挎挖,我揣著相機與錄音这敬,去河邊找鬼。 笑死蕉朵,一個胖子當(dāng)著我的面吹牛崔涂,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播始衅,決...
    沈念sama閱讀 40,468評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼冷蚂,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了汛闸?” 一聲冷哼從身側(cè)響起蝙茶,我...
    開封第一講書人閱讀 39,357評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎诸老,沒想到半個月后隆夯,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,850評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡孕锄,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,002評論 3 338
  • 正文 我和宋清朗相戀三年吮廉,在試婚紗的時候發(fā)現(xiàn)自己被綠了澎语。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片鲫售。...
    茶點故事閱讀 40,144評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖腻扇,靈堂內(nèi)的尸體忽然破棺而出轴脐,到底是詐尸還是另有隱情调卑,我是刑警寧澤,帶...
    沈念sama閱讀 35,823評論 5 346
  • 正文 年R本政府宣布大咱,位于F島的核電站恬涧,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏碴巾。R本人自食惡果不足惜溯捆,卻給世界環(huán)境...
    茶點故事閱讀 41,483評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望厦瓢。 院中可真熱鬧提揍,春花似錦、人聲如沸煮仇。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,026評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽浙垫。三九已至刨仑,卻和暖如春郑诺,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背杉武。 一陣腳步聲響...
    開封第一講書人閱讀 33,150評論 1 272
  • 我被黑心中介騙來泰國打工辙诞, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人艺智。 一個月前我還...
    沈念sama閱讀 48,415評論 3 373
  • 正文 我出身青樓倘要,卻偏偏與公主長得像,于是被迫代替她去往敵國和親十拣。 傳聞我的和親對象是個殘疾皇子封拧,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,092評論 2 355

推薦閱讀更多精彩內(nèi)容