0
我想達到什麼:訪問DOM
亮點在p元素一些文本
(未添加/或刪除)紙徽章時值爲0
根據編號改變紙張徽章顏色
使用示例模塊:
<link rel="import" href="https://polygit2.appspot.com/components/polymer/polymer.html">
<link rel="import" href="https://polygit2.appspot.com/components/iron-icons/communication-icons.html">
<link rel="import" href="https://polygit2.appspot.com/components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="https://polygit2.appspot.com/components/paper-badge/paper-badge.html">
<dom-module id="question-one">
<template>
<template is="dom-repeat" items="{{numbers}}">
<p>color one of my letters</p>
<paper-icon-button id="someid{{index}}" icon="communication:email"></paper-icon-button>
<paper-badge for="someid{{index}}" label="{{item}}"> </paper-badge>
</template>
</template>
<script>
Polymer({
is: "question-one",
properties: {
numbers: {
type: Array,
value: function() {
return [0, 1, 2, 0, 4, 5, 0, 7, 8, 0]
}
}
}
}); </script>
</dom-module>
與用法:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://polygit2.appspot.com/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="questions//question-one.html" />
</head>
<body>
<question-one></question-one>
</body>
</html>
作爲參考,與DOM的記錄在這裏:HTTPS://www.polymer-project。組織/ 1.0 /文檔/ devguide /本地-DOM#DOM的API –