注册一个元素

<link rel="import"
href="bower_components/polymer/polymer.html">
//没有添加<dom-module>
<script>
Polymer({
is:'proto-element',
ready:function(){
this.innerHTML='sfp';
}
})
</script>

增加本地元素:在<template>中

<link rel="import"
href="bower_components/polymer/polymer.html"> <dom-module id="dom-element">
<template>
<p>I'm a DOM element. This is my local DOM!</p>
</template>
</dom-module> <script>
Polymer({
is: "dom-element",
});
</script>

本地元素布局:在main中

<link rel="import"
href="bower_components/polymer/polymer.html"> <dom-module id="picture-frame">
<!-- scoped CSS for this element -->
<style>
div {
display: inline-block;
background-color: #ccc;
border-radius: 8px;
padding: 4px;
}
</style>
<template>
<div>
<!-- any children are rendered here -->
<content></content>
</div>
</template>
</dom-module> <script>
Polymer({
is: "picture-frame",
});
</script>
<!DOCTYPE html>
<html>
<head>
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="picture-frame.html">
</head>
<body>
<picture-frame>
<image src="data:images/p-logo.svg">
</picture-frame>
</body>
</html>

数据绑定:在Polymer()中定义数据,在<template>中显示

<link rel="import"
href="bower_components/polymer/polymer.html"> <dom-module id="name-tag">
<template>
<!-- bind to the "owner" property -->
This is <b>{{owner}}</b>'s name-tag element.
</template>
</dom-module> <script>
Polymer({
is: "name-tag",
ready: function() {
// set this element's owner property
this.owner = "Daniel";
}
});
</script> 

声明properties:看起来跟数据绑定功能类似,其实是要序列化为attribute;声明attribute,用hostAttributes

<link rel="import"
href="bower_components/polymer/polymer.html"> <dom-module id="configurable-name-tag">
<template>
<!-- bind to the "owner" property -->
This is <b>{{owner}}</b>'s configurable-name-tag element.
</template>
</dom-module> <script>
Polymer({
is: "configurable-name-tag",
properties: {
// declare the owner property
owner: {
type: String,
value: "Daniel"
}
}
});
</script>

绑定properties:把定义的值传给属性

<link rel="import"
href="bower_components/polymer/polymer.html">
<dom-module id='proto-element'>
<style>
div{
width:100px;
height:100px;
background-color:olive;
}
</style>
<template>
<div>
<p id='{{owner}}'>local dom</p>
<content></content>
</div>
</template>
</dom-module>
<script>
Polymer({
is:'proto-element',
properties:{
owner:{
type:String,
value:'bind properties'
}
} })
</script>

绑定数据和ready:声明了一个属性owner,default value:'wj', ready 之后改为'sfp'

<link rel="import"
href="bower_components/polymer/polymer.html">
<!-- 需要加一个id,value为proto-element -->
<dom-module id='proto-element'>
<template>
    //增加本地元素
<p>this is a local dom</p>
<p><strong>{{owner}}</strong> test data binding</p>
</template>
</dom-module>
<script>
Polymer({
is: "proto-element",
ready: function() {
this.owner='sfp'; },
properties:{
owner:{
type:String,
value:'wj'
}
}
});
</script>

  

 

  

polymer-quick tour of polymer的更多相关文章

  1. A quick tour of JSON libraries in Scala

    A quick tour of JSON libraries in Scala Update (18.11.2015): added spray-json-shapeless libraryUpdat ...

  2. 【转】Polymer API开发指南 (二)(翻译)

    原文转自:http://segmentfault.com/blog/windwhinny/1190000000596258 公开 property 当你公开一个 Polymer 元素的 propert ...

  3. Polymer——Web Components的未来

    什么是polymer? polymer由谷歌的Palm webOS团队打造,并在2013 Google I/O大会上推出,旨在实现Web Components,用最少的代码,解除框架间的限制的UI 框 ...

  4. Polymer初探

    Polymer是什么? Polymer英文为 n.聚合物:多聚体 网络高分子:聚合体:高分子聚合物 应用在Web组件场景, 表达的是, 一个一个小的Web组件,可以通过此框架聚合为一个 整个页面. h ...

  5. 前端组件化Polymer入门教程(4)——自定义元素

    除了上一篇说到的创建自定义元素方法以外,还可以通过原生JS来创建,当你需要动态的创建元素时可以通过这种方式. template.html <link rel="import" ...

  6. Polymer API开发指南 (二)(翻译)

    公开 property 当你公开一个 Polymer 元素的 property 名字时,就等于把这个 property 设置为公开API了.公开 property 会有如下的特性: 支持声明数据双向绑 ...

  7. 【转】组件化的Web王国

    本文由 埃姆杰 翻译.未经许可,禁止转载!英文出处:Future Insights. 内容提要 使用许多独立组件构建应用程序的想法并不新鲜.Web Component的出现,是重新回顾基于组件的应用程 ...

  8. [译] MongoDB Java异步驱动快速指南

    导读 mongodb-java-driver是mongodb的Java驱动项目. 本文是对MongoDB-java-driver官方文档 MongoDB Async Driver Quick Tour ...

  9. arcgis arcengine Using environment settings

    In this topic About using environment settings Environment settings summary table About using enviro ...

随机推荐

  1. 【python】Beautiful Soup的使用

    1. Beautiful Soup的简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据.官方解释如下: Beautiful Soup提供一些简单的.pyt ...

  2. Hive文件的存储格式

    hive文件存储格式包括以下几类: TEXTFILE SEQUENCEFILE RCFILE 自定义格式 其中TEXTFILE为默认格式,建表时不指定默认为这个格式,导入数据时会直接把数据文件拷贝到h ...

  3. aix操作系统的版本中TL SP 含义

    AIX 分为四个主要的操作系统级别:版本.发行版.技术级 (TL) 和服务包 (SP).版本和发行版通常指的是 AIX 的名称,例如AIX 7.1.TL 是包含重大更新的操作系统的发行版,而 SP 包 ...

  4. Spring Boot使用@Scheduled定时器任务

      摘要: Spring Boot之使用@Scheduled定时器任务 假设我们已经搭建好了一个基于Spring Boot项目,首先我们要在Application中设置启用定时任务功能@EnableS ...

  5. 分布式锁实践(一)-Redis编程实现总结

    写在最前面 我在之前总结幂等性的时候,写过一种分布式锁的实现,可惜当时没有真正应用过,着实的心虚啊.正好这段时间对这部分实践了一下,也算是对之前填坑了. 分布式锁按照网上的结论,大致分为三种:1.数据 ...

  6. selenium+python自动化81-html报告优化(饼图+失败重跑+兼容python2&3)

    优化html报告 为了满足小伙伴的各种变态需求,为了装逼提升逼格,为了让报告更加高大上,测试报告做了以下优化: 测试报告中文显示,优化一些断言失败正文乱码问题 新增错误和失败截图,展示到html报告里 ...

  7. WebLogic Server StuckThreadMaxTime value is exceeded during configuration

    WebLogic Server StuckThreadMaxTime value is exceeded during configuration If you are configuring Web ...

  8. 问题记录,StartCoroutine(“str")问题

    StartCoroutine参数为函数字符串名,运行时出错,错误是:无法启动协程函数. 调用格式如下: gameManager.StartCoroutine(LuaOnLevelwasloaded() ...

  9. 分享 - 普通程序员如何转向AI方向

    原作者:计算机的潜意识 原文链接,内容稍有改动,侵删 1. 目的2. AI领域简介3. 学习方法4. 学习路线 0) 领域了解1) 知识准备2) 机器学习3) 实践做项目4) 深度学习5) 继续机器学 ...

  10. latex如何插入空白行

    1.~\\:一行空白2.\\[行距]:可加入任意间距的空白行 [xpt]