注册和声明周期

my = Polymer({
is: "proto-element",
created: function() {
this.innerHTML = 'created';
}
});
//注册之后会返回构造函数,创建实例的两种方法
var el1 = document.createElement('proto-element');
var el2 = new my();

使用polymer注册自定义元素,created function 中的this.innerHTML='sfp',不会被执行

传递参数需要使用factoryImpl,这样的话,只能通过构造函数来创建实例

在元素初始化(本地dom建立,默认值设定)之后,才调用factoryImpl

现在只支持扩展本地元素(给input加其他的样式),而不支持扩展自定义元素。扩展实例

MyInput = Polymer({
is: 'my-input',
extends: 'input',
created: function() {
this.style.border = '1px solid red';
}
}); var el1 = new MyInput();
console.log(el1 instanceof HTMLInputElement); // true var el2 = document.createElement('input', 'my-input');
console.log(el2 instanceof HTMLInputElement); // true //使用
<input is="my-input">

声明周期内的回调函数:created,attached,detached,attributeChanged,ready

ready: function() {
<!-- access a local DOM element by ID using this.$ -->
//自动发现节点
this.$.header.textContent = 'Hello!';
}

polymer()中可以加的函数有以上5个,或者createdCallback, attachedCallback, detachedCallback, attributeChangedCallback。

元素初始化的顺序:

created callback
local DOM constructed
default values set
ready callback
factoryImpl callback
attached callback

回调函数的注册?看不懂

设定属性

Polymer({
is: 'x-custom',
hostAttributes: {
role: 'button',
'aria-disabled': true,
tabindex: 0
}
});
//效果:<x-custom role="button" aria-disabled tabindex="0"></x-custom>

只设定元素的原型,而不立即注册它

var MyElement = Polymer.Class({
is: 'my-element',
// See below for lifecycle callbacks
created: function() {
this.innerHTML = 'My element!';
}
});
//现在注册
document.registerElement('my-element', MyElement);
var el = new MyElement();

polymer-developer guide-registration and lifecycle的更多相关文章

  1. Ehcache(2.9.x) - API Developer Guide, Cache Loaders

    About Cache Loaders A CacheLoader is an interface that specifies load() and loadAll() methods with a ...

  2. Ehcache(2.9.x) - API Developer Guide, Key Classes and Methods

    About the Key Classes Ehcache consists of a CacheManager, which manages logical data sets represente ...

  3. Ehcache(2.9.x) - API Developer Guide, Cache Usage Patterns

    There are several common access patterns when using a cache. Ehcache supports the following patterns ...

  4. Ehcache(2.9.x) - API Developer Guide, Searching a Cache

    About Searching The Search API allows you to execute arbitrarily complex queries against caches. The ...

  5. Ehcache(2.9.x) - API Developer Guide, Write-Through and Write-Behind Caches

    About Write-Through and Write-Behind Caches Write-through caching is a caching pattern where writes ...

  6. Ehcache(2.9.x) - API Developer Guide, Cache Manager Event Listeners

    About CacheManager Event Listeners CacheManager event listeners allow implementers to register callb ...

  7. Ehcache(2.9.x) - API Developer Guide, Cache Extensions

    About Cache Extensions Cache extensions are a general-purpose mechanism to allow generic extensions ...

  8. Ehcache(2.9.x) - API Developer Guide, Cache Eviction Algorithms

    About Cache Eviction Algorithms A cache eviction algorithm is a way of deciding which element to evi ...

  9. 移动端目标识别(2)——使用TENSORFLOW LITE将TENSORFLOW模型部署到移动端(SSD)之TF Lite Developer Guide

    TF Lite开发人员指南 目录: 1 选择一个模型 使用一个预训练模型 使用自己的数据集重新训练inception-V3,MovileNet 训练自己的模型 2 转换模型格式 转换tf.GraphD ...

  10. Intel® Threading Building Blocks (Intel® TBB) Developer Guide 中文 Parallelizing Data Flow and Dependence Graphs并行化data flow和依赖图

    https://www.threadingbuildingblocks.org/docs/help/index.htm Parallelizing Data Flow and Dependency G ...

随机推荐

  1. JavaWeb的过滤器Filter

    Filter的作用是在请求到达web资源(HTML.css.Servlet.Jsp)之前拦截,做一个预处理. 创建一个类实现Filter接口,在web.xml中对文件进行配置 <filter&g ...

  2. Oracle VM VirtualBox虚拟机安装Ubuntu Server

    安装过程如下:原文转自:http://www.linuxidc.com/Linux/2012-04/59368p8.htm

  3. pythonNet day03

    TCP应用之 httpserver 1.接收http请求 2.查看http请求 3.返回一个网页给客户端 # 做的是一个本地服务端,接收来自浏览器客户端的请求 from socket import * ...

  4. 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #1 如何获取Linux内核

    HACK #1 如何获取Linux内核 本节介绍获取Linux内核源代码的各种方法.“获取内核”这个说法看似简单,其实Linux内核有很多种衍生版本.要找出自己想要的源代码到底是哪一个,必须首先理解各 ...

  5. 读Understanding the Linux Kernel, 3rd Edition有感

    14.3.2.2. Avoiding request queue congestion Each request queue has a maximum number of allowed pendi ...

  6. windows中dos命令指南

    CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本.文件系统版本)chcp 修改默认字符集chcp 936默认中文chcp 650011. appwiz.c ...

  7. ASP.NET web 应用程序项目

    ASP.NET web  应用程序项目 .ashx .ashx.cs aspx包括前台一些代码要处理,ashx可以看作是没有aspx页面中前台代码的后台.cs文件. 没有了前台代码,服务器负担少一点, ...

  8. java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus

    solution Step: 1.In the classpath tab, be sure to add the wlclient.jar file located here \wlserver_1 ...

  9. Eclipse安装Freemarker Editor插件

    在下面网址里下载freemarker-ide: http://sourceforge.net/projects/freemarker-ide/files/ 下载完成后后解压,由于该IDE里面的free ...

  10. LPCTSTR和LPTSTR和char *究竟有什么区别

    LPSTR = char* LPCSTR = const char* LPTSTR: 如果定义了UNICODE宏,那么LPTSTR = wchar_t*否则LPTSTR = char* LPCTSTR ...