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 ...
随机推荐
- Linux学习系列之Nginx调优实战
Nginx配置文件性能微调 全局的配置 user www-data; pid /var/run/nginx.pid; worker_processes auto; worker_rlimit_nofi ...
- Navicat Premium解决连接mssql报错的问题
连接名:mssql_172.16.30.21:1433,每次打开查询时就报错. 重启,重转都不好使. 解决办法:去掉“:1433”,因为文件目录不支持“:”,所以一直报错.问题终于得到解决.
- [DP题]吃糖果
1944:吃糖果 总时间限制:1000ms内存限制:65536kB 描述 名名的妈妈从外地出差回来,带了一盒好吃又精美的巧克力给名名(盒内共有 N 块巧克力,20 > N >0).妈妈告诉 ...
- 汇编_指令_FLAGS
标志名 标志 1 标志 0 OF (溢出标志) OV ...
- 租用游艇(简单区间dp)
租用游艇 时间限制: 1 Sec 内存限制: 128 MB提交: 1 解决: 1[提交][状态][讨论版][命题人:quanxing] 题目描述 长江游艇俱乐部在长江上设置了n 个游艇出租站1,2 ...
- python一些不错的东西
1 cmd命令行写代码的加强版 ipython 直接用pip安装就可以 php install Ipython 2 不错的数据分析 机器语言的 Python(x,y)是一个基于python的科 ...
- 765. Couples Holding Hands
▶ n 对夫妻共 2n 个人随机坐成一排,“交换其中某两人的位置” 称为一次操作,求最少的操作此次数,使 n 对夫妻两人都相邻.初始座位为非负整数列 D1n-1,其中值为 2k 和 2k+1 的两个元 ...
- Ubuntu 安装VNC
ubuntu:.安装x11vnc sudo apt-get install x11vnc .设置密码 x11vnc -storepasswd .启动x11vnc(每次windows远程控制,都需要启动 ...
- windows 下 YII2 配置 memcache
环境: 操作系统 :Windows 7; php: 5.6.8 apche:2.4.12 1.首先安装PHP memcache 拓展,安装方法如下: 1.1下载 memcache 拓展DLL: ht ...
- 跟我学算法-opencv加载,修改,保存
#include<opencv2/opencv.hpp> #include<iostream> #include<math.h> using namespace c ...