聚合物铁选择器多选择器没有出现

时间:2018-02-22 06:20:34

标签: polymer polymer-2.x

我正在尝试<iron-selector>多选的简单测试。我运行了元素附带的演示项目,似乎从那里工作正常,但每当我将它复制到我的项目时,元素都不会出现。我已经制作了一个Plunker来测试它:Plnkr test link。我正在尝试测试多选项(设置并获取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>

1 个答案:

答案 0 :(得分:1)

看起来你只是忘了为所选元素设置样式。例如,您可以将所选元素的背景设置为浅灰色:

<style>
  .iron-selected {
    background: #eee;
  }
</style>

demo