聚合物中的DOM访问
我想要达到的目标:聚合物中的DOM访问,dom,module,polymer,Dom,Module,Polymer,我想要达到的目标: 突出显示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/communicatio
<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>
给我的一封信涂上颜色
聚合物({
是:“第一个问题”,
特性:{
编号:{
类型:数组,
值:函数(){
返回[0,1,2,0,4,5,0,7,8,0]
}
}
}
});
使用方法:
<!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>
添加一个
id
属性
<p id="someId">
this.$
不适用于动态添加的HTML或template is=“dom if”或template is=“dom repeat”或类似内容中的HTML
对于这种情况,您可以使用this.$$(选择器)
来支持所有CSS选择器,而this.$…
只支持id
(不支持)添加id
属性
<p id="someId">
this.$
不适用于动态添加的HTML或template is=“dom if”或template is=“dom repeat”或类似内容中的HTML
在这种情况下,您可以使用this.$$(选择器)
来支持所有CSS选择器,而this.$…
只支持id
(不支持)作为参考,使用DOM的过程记录在此处:作为参考,使用DOM的过程记录在此处: