polymer-developer guide-registration and lifecycle
注册和声明周期
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Ehcache(2.9.x) - API Developer Guide, Cache Manager Event Listeners
About CacheManager Event Listeners CacheManager event listeners allow implementers to register callb ...
- Ehcache(2.9.x) - API Developer Guide, Cache Extensions
About Cache Extensions Cache extensions are a general-purpose mechanism to allow generic extensions ...
- 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 ...
- 移动端目标识别(2)——使用TENSORFLOW LITE将TENSORFLOW模型部署到移动端(SSD)之TF Lite Developer Guide
TF Lite开发人员指南 目录: 1 选择一个模型 使用一个预训练模型 使用自己的数据集重新训练inception-V3,MovileNet 训练自己的模型 2 转换模型格式 转换tf.GraphD ...
- 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 ...
随机推荐
- MySQL分段统计SQL写法 与 Mybatis 异常 java.math.BigDecimal cannot be cast to java.lang.Integer
mysql> select end) as '<60', end) as '60~69', end) as '70~79', end) as '80~89', end) as '>= ...
- 二、jdk命令之javah命令(C Header and Stub File Generator)
目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...
- Ubantu 网卡绑定固定IP
# The primary network interface auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 192.1 ...
- Building Your First App(创建你的第一个应用程序)
欢迎来到Android应用开发 这部分课程将教你如何创建你的第一个android应用程序,包括如何创建一个android项目以并且在可调试模式下去运行这个应用程序, 您还将学习关于Android的应用 ...
- c#,条码
static void Generate2(string text){ BarcodeWriter writer = new BarcodeWriter(); //使用ITF 格式,不能被现在常用的支 ...
- 设置 UILabel 和 UITextField 的 Padding 或 Insets (理解UIEdgeInsets)
转自http://unmi.cc/uilable-uitextfield-padding-insets 主要是理解下UIEdgeInsets在IOS UI里的意义. 靠,这货其实就是间隔,起个名字这么 ...
- Android提交自己的作品到GitHub上
最近在做一个期待上架的我个人写的App,我打算将它开源出去,托管到GitHub上.看了一下网上的教程,其实五花八门,我照着做了,还是没法提交到GitHub上.自己研究了一下,其实非常的简单.这里决定介 ...
- ConcurrentHashMap的简单理解
一.效率低下的HashTable容器HashTable容器使用synchronized来保证线程安全,但在线程竞争激烈的情况下HashTable的效率非常低下.因为当一个线程访问HashTable的同 ...
- 77. Combinations (Recursion)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- c语言静态断言
在php中可以通过xdebug来显示详细的错误信息,可以细化到哪个文件哪行代码引起的报错.在C语言里面也可以通过静态断言(assert)来使得调试代码更加方便.关于断言,可以作为一种很强大的调试方式或 ...