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 ...
随机推荐
- 扩展Linq的Distinct方法动态根据条件进行筛选
声明为了方便自己查看所以引用 原文地址:http://www.cnblogs.com/A_ming/archive/2013/05/24/3097062.html Person1: Id=1, Nam ...
- EF调用存储过程查询表中的部分字段,报数据读取器与指定的“AdventureWorksDWModel.Student”不兼容。某个类型为“Age”的成员在同名的数据读取器中没有对应的列。
实现功能:查询单张表Student中返回指定的列 一:数据库表结构: 二:存储过程: USE [AdventureWorksDW] GO /****** Object: StoredProcedure ...
- Bootstrap-Plugin:插件概览
ylbtech-Bootstrap-Plugin:插件概览 1.返回顶部 1. Bootstrap 插件概览 在前面 布局组件 章节中所讨论到的组件仅仅是个开始.Bootstrap 自带 12 种 j ...
- Train-Alypay-Cloud:分布式微服务中间件sofa 开发培训(第二次)
ylbtech-Train-Alypay-Cloud:分布式微服务中间件sofa 开发培训(第二次) 1.返回顶部 1. 这是本次培训的内容,望各位提前配好环境.工具.2.6-2.7 我们在环球金融8 ...
- 记一次 在 HP zbook G3 笔记本上安装Ubuntu16.04LTS 的 心(填)路(坑)旅程
背景 同事MM申请的新笔记本暂时没有用,问我需不需要用. 本着 “宇宙都是xx的”(厚颜无耻~~)思想就接受了. 拿到本本一看,HP zbook G3, 配置还不错(500G SSD, 16G mem ...
- 第八章(三)基于Listcheck适配器的访问控
denier适配器访问控制比较死板.Listchecker的适配器更加灵活. 定义handler: apiVersion: config.istio.io/v1alpha2 kind: listche ...
- Codeforces Round #486-F.Rain and Umbrellas题解
一.题目链接:http://codeforces.com/contest/988/problem/F 二.题面 三.思路 很明显而且比较能想到的$dp$. 四.代码实现 #include<bit ...
- solr学习之六--------Analyzer(分析器)、Tokenizer(分词器)
首先,不知道大家在前面的例子中没有试着搜索文本串,就是在第二节,我们添加了很多文档.如果字段值是一个文本.你如果只搜索这个字段的某个单词,是不是发现搜不到? 这就是因为我们没有配置Analyzer,因 ...
- oracle创建新数据库
oracle创建新数据库 look here http://www.cnblogs.com/phoenixzq/p/3510854.html windows start menu>Oracle& ...
- CPU GPU FPU TPU 及厂商
1,AMD 既做CPU又做显卡2,Inter 全球最大的CPU厂商,GPU,FPGA3,NVIDA 人工智能起家的公司,且一直在做,显卡最出名,CUDA让N卡胜了AMD CPU上 AMD - Inte ...