注册和声明周期

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. unity代码添加动画,并传参数

    测试界面 button一个 sprite一个 测试代码 public class BgObject : MonoBehaviour { void Start() { List<string> ...

  2. Fragment 横竖屏切换问题

    转自:http://my.oschina.net/u/614511/blog/76444 在默认情况下当发生横竖屏切换时,当前Activity中的fragment都会通过Fragment.instan ...

  3. 【ZZ】Web开发的入门指导 | 菜鸟教程

    Web开发的入门指导 http://www.runoob.com/w3cnote/a-beginners-guide-to-web-development.html

  4. [经验]PLSQL乱码解决

    本文摘自:http://jingyan.baidu.com/article/36d6ed1f2861f41bcf488327.html @echo off set path=D:\Program Fi ...

  5. javascript精髓篇之原型链维护和继承.

    一.两个原型 很多人都知道javascript是原型继承,每个构造函数都有一个prototype成员,通过它就可以把javascript的继承演义的美轮美奂了. 其实啊,光靠这一个属性是无法完成jav ...

  6. 第3课 QT的诞生和本质

    1. GUI用户界面元素 (1)操作系统提供了创建用户界面元素所需要的函数 (2)各种功能不同的函数依次调用,从而创建出界面元素 (3)操作系统提供的原生函数无法直接映射到界面元素 2. 面向对象的G ...

  7. 读取配置文件工具demo

    //读取配置文件public class ResourcesUtils { /* * @description:根据属性获取文件名 * * @param:propertyName文件的属性名 * * ...

  8. Selenium2+python自动化63-简易项目搭建

    前言 到unittest这里基本上可以搭建一个简易的项目框架了,我们可以用一条run_main.py脚本去控制执行所有的用例,并生成报告,发送邮件一系列的动作 一.新建工程 1.打开pycharm左上 ...

  9. ubantu环境下fidder安装

    转自:http://www.cnblogs.com/jcli/p/4474332.html Linux(Ubuntu)环境下使用Fiddler 自己的开发环境是Ubuntu, 对于很多优秀的软件但是又 ...

  10. 关于微信小程序的一些看法和理解

    最近做了几个小时的调研,微信小程序 微信小程序是可以理解成在微信中的APP,他的目标是APP的替代者,由于目前的APP主要区分安卓和IOS,或者其他平台, 那么微信小程序的平台在微信,在任何一个手机系 ...