聚合物铁选择器多选器未出现
polymer iron-selector multi selector not appearing
我正在尝试 <iron-selector>
multi select 的简单测试。我 运行 元素附带的演示项目似乎从那里工作正常,但每当我将它复制到我的项目时,元素都不会出现。我做了一个 Plunker 来测试它:Plnkr test link。我正在尝试测试 multi select 选项(设置和获取 selected-values
)。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<script src="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/paper-toast/paper-toast.html">
<link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/iron-selector/iron-selector.html">
</head>
<body>
<p>Start:</p>
<iron-selector multi selected-values="[0,2]">
<div>Item 0</div>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</iron-selector>
<p>End:</p>
<paper-toast text="Polymer is working!" opened></paper-toast>
</body>
</html>
您似乎只是忘记设置所选元素的样式。例如,您可以将所选元素的背景样式设置为浅灰色:
<style>
.iron-selected {
background: #eee;
}
</style>
我正在尝试 <iron-selector>
multi select 的简单测试。我 运行 元素附带的演示项目似乎从那里工作正常,但每当我将它复制到我的项目时,元素都不会出现。我做了一个 Plunker 来测试它:Plnkr test link。我正在尝试测试 multi select 选项(设置和获取 selected-values
)。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<script src="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/paper-toast/paper-toast.html">
<link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/2.3.1/lib/iron-selector/iron-selector.html">
</head>
<body>
<p>Start:</p>
<iron-selector multi selected-values="[0,2]">
<div>Item 0</div>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</iron-selector>
<p>End:</p>
<paper-toast text="Polymer is working!" opened></paper-toast>
</body>
</html>
您似乎只是忘记设置所选元素的样式。例如,您可以将所选元素的背景样式设置为浅灰色:
<style>
.iron-selected {
background: #eee;
}
</style>