简体   繁体   English

聚合物1.0默认图标设置在铁图标不工作使用火焰(流星)模板引擎

[英]Polymer 1.0 default icon set in iron-icons not working using blaze (meteor) templating engine

After upgrading to Polymer 1.0, default iron-icons set is not working. 升级到Polymer 1.0后,默认的iron-icons设置无效。 I am trying to use home icon from the default icon set. 我正在尝试使用默认图标集中的主页图标。

HTML code fragment: HTML代码片段:

    <link rel="import" href="/components/iron-flex-layout/classes/iron-flex-layout.html">
    <link rel="import" href="/components/iron-icons/iron-icons.html">
    <link rel="import" href="/components/iron-icons/communication-icons.html">
    <link rel="import" href="/components/iron-form/iron-form.html">
    <link rel="import" href="/components/iron-selector/iron-selector.html">
    <link rel="import" href="/components/iron-pages/iron-pages.html">

    <!-- OOTB paper elements -->
    <link rel="import" href="/components/paper-drawer-panel/paper-drawer-panel.html">
    <link rel="import" href="/components/paper-header-panel/paper-header-panel.html">
    <link rel="import" href="/components/paper-toolbar/paper-toolbar.html">

    <link rel="import" href="/components/paper-icon-button/paper-icon-button.html">
    <link rel="import" href="/components/paper-material/paper-material.html">

    <link rel="import" href="/components/paper-menu/paper-menu.html">
    <link rel="import" href="/components/paper-item/all-imports.html">

    <link rel="import" href="/components/paper-tabs/paper-tab.html">
    <link rel="import" href="/components/paper-tabs/paper-tabs.html">
    <link rel="import" href="/components/paper-tabs/paper-tabs-icons.html">

<paper-icon-item id="socialFeed">

        <iron-icon icon="home" item-icon></iron-icon>

        <paper-item-body two-line>
          <div>Social Feed</div>
          <div secondary>2 Unread FB Posts</div>
        </paper-item-body>

</paper-icon-item>

I am getting a warning in Chrome debugger: [iron-icon::_updateIcon]: could not find iconset icons, did you import the iconset? 我在Chrome调试器中收到警告: [iron-icon::_updateIcon]: could not find iconset icons, did you import the iconset? @ line#167 in iron-icon.html @ line#167 in iron-icon.html

Debugging showed that in line 163 in iron-icon.html which is 调试显示在iron-icon.html的第163行中

this._iconset = this.$.meta.byKey(this._iconsetName);

this._iconsetName has value "icons" but this._iconset is undefined. this._iconsetName值为“icons”,但this._iconset未定义。

Am I missing some import or something here? 我错过了一些进口或其他什么吗?

EDIT This issue occurs only while using Blaze template engine in Meteor. 编辑只有在Meteor中使用Blaze模板引擎时才会出现此问题。 Just wanted to add this bit for the complete picture. 只想添加这一位以获得完整的图片。

Got the real solution now (not workaround), therefore opened new answer. 现在得到了真正的解决方案(不是解决方法),因此开启了新的答案。

The cause of the warning in Chrome debugger is due to the wrong timing of loading the link imports in the right sequence. Chrome调试器中出现警告的原因是错误的按正确顺序加载链接导入的时间。

Solution: 解:

1.) Remove link imports in the iron-icons (and other icon-sets if needed, like maps, social, etc ...): 1.)删除铁图标中的链接导入 (如果需要,还可以删除其他图标集,如地图,社交等...):

  • public 上市
    • bower_components bower_components
      • iron-icons 铁图标
        • iron-icons.html 铁icons.html
        • maps-icons.html (optional, if you are using them) maps-icons.html(可选,如果你使用它们)
        • social-icons.html (optional, if you are using them) social-icons.html(可选,如果你使用它们)

iron-icons.html: 铁icons.html:

before: 之前:

<!--@group Iron Elements
@element iron-icons
@demo demo/index.html
-->
<link rel='import' href='../iron-icon/iron-icon.html'>
<link rel='import' href='../iron-iconset-svg/iron-iconset-svg.html'>

<iron-iconset-svg name="icons" size="24">
    <svg><defs>
    <g id="3d-rotation"><path d="M7.52 21.48C ..... etc ..... /></g>
    </defs></svg>
</iron-iconset-svg>

after: 后:

<!--@group Iron Elements
@element iron-icons
@demo demo/index.html
-->
<!--<link rel='import' href='../iron-icon/iron-icon.html'>
<link rel='import' href='../iron-iconset-svg/iron-iconset-svg.html'>-->

<iron-iconset-svg name="icons" size="24">
    <svg><defs>
    <g id="3d-rotation"><path d="M7.52 21.48C ..... etc ..... /></g>
    </defs></svg>
</iron-iconset-svg>

The initial link-imports (dependencies) are blocking (not loading async but sync, which is good because that's the way it should be). 最初的链接导入(依赖关系)是阻塞的(不加载异步但是同步,这很好,因为它应该是这样的)。 However, within the code of <link rel='import' href='../iron-icon/iron-icon.html'> iron-icon is making reference to the icon set that could not load yet ( <iron-iconset-svg name="icons" size="24"> etc ...) because it comes after that initial link-import (due to blocking nature of link import). 但是,在<link rel='import' href='../iron-icon/iron-icon.html'>的代码中, <link rel='import' href='../iron-icon/iron-icon.html'> iron-icon正在引用尚未加载的图标集( <iron-iconset-svg name="icons" size="24"> etc ...)因为它是在初始链接导入之后(由于链接导入的阻塞性质)。 Hence, at line 164 it cannot find the Default iconset icons , and therefore throwing the famous warning at line 167: 因此,在第164行,它找不到默认图标集图标 ,因此在第167行抛出着名的警告:

could not find iconset icons, did you import the iconset? 找不到iconset图标,你导入了iconset吗?

2.) Load required dependencies in your project file in the correct sequence: 2.)以正确的顺序在项目文件中加载所需的依赖项

<head>
  <meta charset="utf-8" />
  <title></title>

  <script src="/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
  <link rel="import" href="/bower_components/polymer/polymer.html">

  <link rel="import" href="/bower_components/iron-meta/iron-meta.html">
  <link rel="import" href="/bower_components/iron-flex-layout/iron-flex-layout.html">
  <link rel="import" href="/bower_components/iron-iconset-svg/iron-iconset-svg.html">
  <link rel="import" href="/bower_components/iron-iconset/iron-iconset.html">

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

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

The <link rel="import" href="/bower_components/iron-icon/iron-icon.html"> is loaded in last position now, hence all dependencies are available at this point. <link rel="import" href="/bower_components/iron-icon/iron-icon.html">现在加载到最后一个位置,因此此时所有依赖项都可用。

Works like a charm for me now. 对我来说就像是一种魅力。

@LuckyRay's : Please let us know whether this works for you, too. @LuckyRay's:请告诉我们这是否也适合您。 I will post this on your github comment for the Polymer Team as well. 我也会在聚合物团队的github评论中发布此信息。

I had same issue. 我有同样的问题。 Seems to be related to <paper-icon-item> . 似乎与<paper-icon-item> Try to replace it with <paper-icon-button> meanwhile (I quickly reproduced your code and it worked for me: at least your home-icon is showing up corrrectly now). 尝试同时用<paper-icon-button>替换它(我快速复制你的代码,它对我有用:至少你的主页图标现在正确显示)。 Maybe someone else has another comment on this issue. 也许其他人对这个问题有另一个评论。

Hence, your HTML: 因此,您的HTML:

<paper-icon-button icon="home" id="socialFeed">
  <paper-icon-item>
        <paper-item-body two-line>
          <div>Social Feed</div>
          <div secondary>2 Unread FB Posts</div>
        </paper-item-body>
  </paper-icon-item>
</paper-icon-button> 

The <paper-item-body two-line> not showing within the button, though (or maybe try styling button -> enlarge, etc ... and fiddle around a bit). 虽然没有在按钮内显示<paper-item-body two-line> (或者可能尝试造型按钮 - >放大等等...并且稍微摆弄一下)。 Hope this helps meanwhile anyway as a quick workaround .... 希望这有助于同时作为快速解决方法....

Polymer 1.0 rocks, though. 然而,聚合物1.0岩石。 Worth the effort .... good job from the Polymer Team, thanks. 值得努力......来自Polymer Team的好工作,谢谢。 Lucky us .... :-) 幸运的我们...... :-)

Just tried it the other way around, putting the icon-button inside the <paper-icon-time> : 只是尝试了反过来,将图标按钮放在<paper-icon-time>

<paper-icon-item>
  <paper-icon-button icon="home" id="socialFeed"></paper-icon-button> 
  <paper-item-body two-line>
    <div>Social Feed</div>
    <div secondary>2 Unread FB Posts</div>
  </paper-item-body>
</paper-icon-item>

There is an experimental way of forcing to use the shadow DOM. 有一种强制使用阴影DOM的实验方法。 Check this forum post at the bottom: https://forums.meteor.com/t/polymer-1-0-and-iron-router-or-flow-router/5148/16 查看底部的论坛帖子: https//forums.meteor.com/t/polymer-1-0-and-iron-router-or-flow-router/5148/16

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM