SlideShare a Scribd company logo
你不能不知道的 
PolymerJS 開發實戰 
2014-08-30 Marty
分享項目 
● 建置本機 Polymer 環境 
● 打造自己的HTML標籤 
● 樣板+雙向繫結 
● 武器庫 
● 資源
WebCompoents 
這是瀏覽器都要支持的約定...
WebCompoents 
但是現況是...
IE反應是慢了一些
WebComponents 支援程度
IE反應是慢了一些
WebComponents 支援程度 (platform.js+)
很明顯,Polymer 幹的是苦差事 (看很遠) 
"X-Tag and Polymer are both 
high-level sugar libraries that 
build upon the W3 Web 
Components specs - each 
introduces a different approach 
to making development of web 
components an even more 
amazing experience. To help 
make this more relatable, 
consider the following: 
jQuery : DOM 
X-Tag/Polymer : WebComponents. 
"
本機環境建置 1/3 安裝 NodeJS、Bower 
1. 裝 nodejs 
2. npm install -g bower 
3. 裝本機Server npm install -g serve 
(或python -m SimpleHTTPServer) 
https://www.youtube.com/watch? 
v=1rz334A8U7o
本機環境建置 2/3 安裝 Polymer 
//先建個目錄 
mkdir polymer 
//進去polymer目錄,進行bower初始化,也就是產生bower.json 
bower init 
//裝 paper元件(Material Design)就好了 
bower install --save Polymer/paper-elements 
//裝 Google 元件 <google-map> (http://googlewebcomponents.github.io) 
bower install --save GoogleWebComponents/google-map
polymer 框架和元件們
本機環境建置 3/3 (確認) 
<!DOCTYPE html> 
<html> 
<head> 
<script src="bower_components/platform/platform.js"></script> 
</head> 
<body> 
<link rel="import"href="bower_components/google-map/google-map.html"> 
<style> 
google-map { 
display: block; 
height: 600px; 
} 
</style> 
<google-map latitude="22.605153" longitude="120.301125" 
disableDefaultUI showCenterMarker zoom="18"></google-map> 
</body> 
</html>
先嘗鮮 <template> bind
先嘗鮮 <template> bind
PolymerJS 開發實戰
實戰#1 - 打造自己的 Element 
Link
打造自己的 Element <post-card> 
<script src="bower_components/platform/platform.js"></script> 
<link rel="import" href="bower_components/core-icons/core-icons.html"> 
<link rel="import" href="bower_components/paper-tabs/paper-tabs.html"> 
<link rel="import" href="bower_components/paper-tabs/paper-tab.html">
打造自己的 Element 
Any <h2> children match the 
second <content> tag and are 
inserted here. 
<post-card>...</post-card> 
insert pointer
如果可以有很多.. 
Link
實戰#2 - template + data-binding
實戰#2 - template + data-binding 
● HTML5 new Tag - <template> 
● Object.observe() - Polymer data-binding
<template> 
template (n) - A document or file having a preset format, used as a starting 
point for a particular application so that the format does not have to be 
recreated each time it is used.
IE反應是慢了一些...
template 用法 (搭配Polymer data-binding) 
<paper-tabs selected="0" role="tablist" id="tab"> 
<template id="tabItem" repeat="{{tabs}}"> 
<paper-tab role="tab">{{name}}</paper-tab> 
</template> 
</paper-tabs> 
var models = { 
tabs: [ {name: 't1' }, { name: 't2'}, {name: 't3' }] 
}; 
$(document).on('polymer-ready', function () { 
$('#tabItem')[0].model = models; 
$('#add').on('click', function () { 
models.tabs.push({ name: 'NewTab' }); 
}); 
$('#del').on('click', function () { 
models.tabs.pop(); 
}); 
}); 
對model操作自動綁定UI
感受一下 paper 元件和雙向綁定 
Link 
Dynamic, 
two-way data binding 
Note: The <template> element is a new 
element in the HTML standard. For 
information on using templates outside of 
Polymer, see HTML’s New Template Tag on 
HTML5Rocks. 
Link
武器庫
人臉追蹤、聲音播放/辨識 
trackingjs.js 
voices Web Component wrapper to the Web 
Speech API, that allows you to do voice 
recognition and speech synthesis using 
Polymer
GoogleSheets + Goole Map (改成雙向,有坑!) 
http://googlewebcomponents.github.io/google-sheets/components/google-sheets/demo.html
Step1 改成 bind model + draggable='true'
Step2 fix google-map updatePosition(...)
Resource 
● Are We Componentized Yet? 
● Data-binding Revolutions with Object.observe() 
● HTML5 ROCKS 
● Component Kitchen 
● Custom Elements 
● http://trackingjs.com/docs.html#web-components

More Related Content

PPT
Jsdc 2013
PDF
Polymer vs other libraries (Devfest Ukraine 2015)
PDF
Polymer
PDF
Booting up with polymer
PDF
웹을 지탱하는 차세대 기술 @한국웹20주년 컨퍼런스
PPTX
Polymer and web component
PDF
Building a Secure App with Google Polymer and Java / Spring
PPTX
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
Jsdc 2013
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer
Booting up with polymer
웹을 지탱하는 차세대 기술 @한국웹20주년 컨퍼런스
Polymer and web component
Building a Secure App with Google Polymer and Java / Spring
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17

What's hot (20)

PPTX
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
PPTX
How to build a web application with Polymer
PDF
HTML5와 오픈소스 기반의 Web Components 기술
PDF
Introduction to polymer project
PDF
Web components api + Vuejs
PDF
Blazor web apps
PDF
Polymer - Lego for the web!
PDF
BP101: A Modernized Workflow w/ Domino/XPages
PDF
Introduction to Web Components
ODP
Front-End Performance Optimizing
PDF
Introduction to Browser Internals
PPTX
Front end optimization
PPT
Front End Website Optimization
TXT
New text document
PPTX
Html5 & less css
PDF
Metarefresh
PDF
Thomas Lobinger
PDF
Beyond PrettyFaces - Einführung in Rewrite
PDF
KAPT Annotation processing & Code generation
PDF
Extensions.pdf
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
How to build a web application with Polymer
HTML5와 오픈소스 기반의 Web Components 기술
Introduction to polymer project
Web components api + Vuejs
Blazor web apps
Polymer - Lego for the web!
BP101: A Modernized Workflow w/ Domino/XPages
Introduction to Web Components
Front-End Performance Optimizing
Introduction to Browser Internals
Front end optimization
Front End Website Optimization
New text document
Html5 & less css
Metarefresh
Thomas Lobinger
Beyond PrettyFaces - Einführung in Rewrite
KAPT Annotation processing & Code generation
Extensions.pdf
Ad

Viewers also liked (17)

PDF
2014南部創新應用工具研討會 快速開發行動 app
PDF
2015 WebConf - Web + Arduino 實在有夠潮
PDF
MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...
PDF
App開發 - Web Developer的逆襲
PDF
Web Components: Rethinking Web App Development
PDF
MAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom Elements
PDF
Web components are the future of the web - Take advantage of new web technolo...
PDF
MAppMechanic CodeLabs - PolymerJS Introduction
PDF
New World of Angular (v2+)
PDF
Intro to Web Components, Polymer & Vaadin Elements
PDF
MAppMechanic CodeLabs - PolymerJS Custom Elements
PDF
Webduino 新功能介紹體驗
PDF
2015 JSDC Build Anything with JavaScript
PPTX
前端工程師的告白: 親愛的,開源的物聯網好好玩呀!
PDF
一拳前端考題
PDF
Web + Arduino 實在有夠潮 ( 課程簡報 )
2014南部創新應用工具研討會 快速開發行動 app
2015 WebConf - Web + Arduino 實在有夠潮
MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...
App開發 - Web Developer的逆襲
Web Components: Rethinking Web App Development
MAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom Elements
Web components are the future of the web - Take advantage of new web technolo...
MAppMechanic CodeLabs - PolymerJS Introduction
New World of Angular (v2+)
Intro to Web Components, Polymer & Vaadin Elements
MAppMechanic CodeLabs - PolymerJS Custom Elements
Webduino 新功能介紹體驗
2015 JSDC Build Anything with JavaScript
前端工程師的告白: 親愛的,開源的物聯網好好玩呀!
一拳前端考題
Web + Arduino 實在有夠潮 ( 課程簡報 )
Ad

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Digital Systems & Binary Numbers (comprehensive )
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Website Design Services for Small Businesses.pdf
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Complete Guide to Website Development in Malaysia for SMEs
Digital Systems & Binary Numbers (comprehensive )
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Website Design Services for Small Businesses.pdf
AutoCAD Professional Crack 2025 With License Key
Navsoft: AI-Powered Business Solutions & Custom Software Development
Designing Intelligence for the Shop Floor.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Patient Appointment Booking in Odoo with online payment
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Weekly report ppt - harsh dattuprasad patel.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Salesforce Agentforce AI Implementation.pdf
Autodesk AutoCAD Crack Free Download 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
iTop VPN Crack Latest Version Full Key 2025

PolymerJS 開發實戰