注册和声明周期

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. ODBC, OLEDB, ADO, ADO.Net的演化简史

    ODBC, OLEDB, ADO, ADO.Net的演化简史 Copy&Paste了一下午,终于一蹴而就此文,嘿嘿... 1.演变历史 它们是按照这个时间先后的顺序逐步出现的,史前->O ...

  2. 慕课网 -- 性能优化之PHP优化总结笔记

    视频链接,感兴趣的可以去看看,对我来说耳目一新. http://www.imooc.com/learn/205 什么情况下遇到PHP性能问题 1 :PHP语法使用不恰当 2 :使用了PHP语言他不擅长 ...

  3. C# 添加xml节点多了xmlns属性问题

    当父节点有xmlns属性时,动态创建子节点,会默认增加一个 xmlns=“” 的节点属性值. 原有 doc.CreateElement("son-node"); 改为 doc.Cr ...

  4. MAMP pro mac 本地集成环境 php sal apache等集成软件

    http://www.sdifen.com/mamppro411.html 已存在我的百度云盘 安装后,打开  MAMP 第一步:配置启动和停止选项 默认启动项.默认停止项,只需要勾选: 1.Star ...

  5. umount时目标忙解决办法

    标签(空格分隔): ceph ceph运维 osd 在删除osd后umount时,始终无法umonut,可以通过fuser查看设备被哪个进程占用,之后杀死进程,就可以顺利umount了. [root@ ...

  6. Git 安装部署

    CentOS6的yum源中已经有git的版本了,可以直接使用yum源进行安装. yum install/remove git 但是yum源中安装的git版本是1.7.1,太老了,Github等需要的G ...

  7. ROS创建Web代理(Web proxy)给QQ使用HTTP代理

    使用Web代理可以提高网页的访问速度,因为访问的数据会存储在内存或是硬盘中,就会直接从代理服务器中读取.同时,为了提高网络访问的安全性,可以给Web代理服务器设置相应的权限,使它的安全性得到提高. 下 ...

  8. C++builder XML XSL 代码生成

    void __fastcall TFrmGenCode::XSLTxml1Click(TObject *Sender) { // XSLT转换xml文件格式 _di_IXMLDocument xml; ...

  9. zookeeper 节点讲解以及实际项目运用

    转自:https://www.jianshu.com/p/86acf1df6cdd 前言:最近工作不是很忙,本应该乘着闲暇的时间看书的,之前每天晚上都要翻翻的,可是自己竟然迷恋上了王晓磊 写的 卑鄙的 ...

  10. UNITY C#内存泄漏

    http://www.360doc.com/content/15/0717/09/10504424_485422031.shtml