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 ...
随机推荐
- 【python】使用Python中的urlparse、urllib抓取和解析网页
一.解析URL 函数urlparse(urlstring [, default_scheme [, allow_fragments]])的作用是将URL分解成不同的组成部分,它从urlstring中取 ...
- [Nlog]使用经验
<?xml version="1.0" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog ...
- mysql 8.0 初识
1 下载并安装mysql 8.0官网下载比较慢,这里选择163的镜像http://mirrors.163.com/mysql/Downloads/MySQL-8.0/下载版本mysql-8.0.14- ...
- Hive组件以及执行过程
对Hive的基本组成进行了总结: 1.组件: 元存储(Metastore )-存储“系统目录以及关于表.列.分区等的元数据”的组件.驱动(Driver )- 控制 HiveQL 生命周期的组件,当 H ...
- 记录在Python2.7 x64 bit 下 PyQt5.8的编译过程
由于工作需要使用python下面的Qt库.PyQt现在只提供针对Python3.X系列的PyQt,所有需要自己手动编译.防止忘记,特意写下随笔记录备忘. 工 作 环境:Python版本:Python ...
- NodeJs通过async/await处理异步
##场景 远古时代 我们在编写express后台,经常要有许多异步IO的处理.在远古时代,我们都是用chunk函数处理,也就是我们最熟悉的那种默认第一个参数是error的函数.我们来模拟一个Mongo ...
- openAL在mac下播放音源结束时判断处理
音频播放完毕,自然停止 alGetSourcei(source[0], AL_BUFFERS_QUEUED, &state); NSLog(@"queued number:%d ...
- zookeeper分布式锁和服务优化配置
转自:https://www.jianshu.com/p/02eeaee4357f?utm_campaign=maleskine&utm_content=note&utm_medium ...
- Selection Tools
[Selection Tools] 1.Marquee Tools. OptionBar其中四年控件涵意如下: 2.Magnetic Lasso Tool,根据属标轨迹自动画点. 3.Magic Wa ...
- du熊的机器人
[du熊的机器人] Description du熊正在玩一个别人刚送给它的机器人.这个机器人只能在一个棋盘中行走,棋盘的左上角格子为(0, 0),右下角格子为(X, Y). du熊控制这个机器人从棋盘 ...