polymer-quick tour of polymer
注册一个元素
<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的更多相关文章
- 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 ...
- 【转】Polymer API开发指南 (二)(翻译)
原文转自:http://segmentfault.com/blog/windwhinny/1190000000596258 公开 property 当你公开一个 Polymer 元素的 propert ...
- Polymer——Web Components的未来
什么是polymer? polymer由谷歌的Palm webOS团队打造,并在2013 Google I/O大会上推出,旨在实现Web Components,用最少的代码,解除框架间的限制的UI 框 ...
- Polymer初探
Polymer是什么? Polymer英文为 n.聚合物:多聚体 网络高分子:聚合体:高分子聚合物 应用在Web组件场景, 表达的是, 一个一个小的Web组件,可以通过此框架聚合为一个 整个页面. h ...
- 前端组件化Polymer入门教程(4)——自定义元素
除了上一篇说到的创建自定义元素方法以外,还可以通过原生JS来创建,当你需要动态的创建元素时可以通过这种方式. template.html <link rel="import" ...
- Polymer API开发指南 (二)(翻译)
公开 property 当你公开一个 Polymer 元素的 property 名字时,就等于把这个 property 设置为公开API了.公开 property 会有如下的特性: 支持声明数据双向绑 ...
- 【转】组件化的Web王国
本文由 埃姆杰 翻译.未经许可,禁止转载!英文出处:Future Insights. 内容提要 使用许多独立组件构建应用程序的想法并不新鲜.Web Component的出现,是重新回顾基于组件的应用程 ...
- [译] MongoDB Java异步驱动快速指南
导读 mongodb-java-driver是mongodb的Java驱动项目. 本文是对MongoDB-java-driver官方文档 MongoDB Async Driver Quick Tour ...
- arcgis arcengine Using environment settings
In this topic About using environment settings Environment settings summary table About using enviro ...
随机推荐
- 2019第十届蓝桥杯C/C++
这是我第一次参加蓝桥杯比赛,比完后,有点低于预期,自己的发挥低于预期,赛事水准也低于预期. 教室里面很多同学的电脑出现问题,举办学校也没有完善的应急方案,有一部分同学11点钟才可以做题. 附题目pdf ...
- HDU 4762 Cut the Cake(高精度)
Cut the Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- Bootstrap-Other:可视化布局
ylbtech-Bootstrap-Other:可视化布局 1.返回顶部 1. 2. 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 1. http://www.runoob.co ...
- 利用VMware在虚拟机上安装Zookeeper集群
http://blog.csdn.net/u010246789/article/details/52101026 利用VMware在虚拟机上安装Zookeeper集群 pasting
- JAVA中方法和变量在继承中的覆盖和隐藏(一)
我们知道,在JAVA中,子类可以继承父类,如果子类声明的方法与父类有重名的情况怎么办,大伙儿都知道要是重写,但是实际上这又分为两种情况,就是方法和变量在继承时的覆盖和隐藏问题,这些概念性的东西看似无聊 ...
- kettle步骤概览--清洗校验
2017年03月22日 11:01:19 阅读数:4755 前边介绍了34个子程序 关于清洗和校验的子系统包含四个: 清洗.错误处理.审计维度.排重 Kettle里没有单一的数据清洗步骤,但有很多 ...
- django-DIL模板自定义过滤器,自定义标签,自定义包含标签
自定义过滤器 DTL模板语言生来只是为了方便的展示信息,所以与编程语言相比显得有点薄弱,有时候不能满足我们的需求.因此django提供了一个接口,让开发者能自定义标签和过滤器. 首先,你需要添加一个t ...
- django-url命名空间+反查
from django.conf.urls import url, include urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^h ...
- [代码]set容器查找操作使用
对于set容器来说,查找功能是该容器的主要优势,故针对该容器查找功能作一测试. 主要有如下API接口: 测试源码如下: #include<set> void test(){ set< ...
- vb.net 与 c# 运算符区别
vb.net vs c# 详细的Operators运算符区别 vb.net ===================== Comparison = < > <= >= <& ...