【问题标题】:Material icon not displayed inside a paper-icon-button (Polymer)纸张图标按钮(聚合物)内未显示材料图标
【发布时间】:2018-04-23 16:45:50
【问题描述】:

我在一个项目中使用 Polymer,我只想显示一个汉堡菜单。问题是我可以看到可点击区域,但未显示汉堡菜单。这是我的代码:

<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="shared-styles.html">
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">

<dom-module id="my-view3">
  <template>
    <style include="shared-styles">
      :host {
        display: block;

        padding: 10px;
      }
    </style>

    <paper-icon-button icon="menu"></paper-icon-button>

  </template>

  <script>
    class MyView3 extends Polymer.Element {
      static get is() { return 'my-view3'; }
    }

    window.customElements.define(MyView3.is, MyView3);
  </script>
</dom-module>

对不起我的英语,我是法国人。

【问题讨论】:

    标签: javascript polymer polymer-2.x


    【解决方案1】:

    paper-icon-button 只负责按钮样式和行为,但本身没有 SVG 图标。

    为了能够使用 Google Material 图标,您必须先导入 Iron Icons 元素。

    你必须通过 Bower 安装它(如果你还没有的话):

    bower install --save iron-icons

    然后你必须将它导入到你想要使用图标的组件中。

    <link rel="import" href="../bower_components/iron-icons/iron-icons.html">
    

    【讨论】:

    • 感谢您的回复。问题是我的 bower_components 中没有“iron-icons”文件夹。我只有一个“铁图标”文件夹。
    • @DorianSeguin 你需要安装铁图标bower install --save iron-icons
    • @HyyanAboFakher 非常感谢,它有效。祝你有美好的一天!
    • @DorianSeguin 太好了,别忘了给答案点赞:)
    • 感谢@HyyanAboFakher 提出的修改建议。我还添加了更详尽的描述。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 2016-03-20
    • 2015-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多