【问题标题】:SVG sprites in helper function辅助函数中的 SVG 精灵
【发布时间】:2018-08-16 05:34:35
【问题描述】:

我使用这样的 svg 精灵:

<svg><use href="combined.svg#filter_sent"></use></svg>

Meteor/Blaze 模板助手中,不会渲染 svg 精灵:

<div class="colorset">
    {{{color}}}
</div>


color: function () {
    if (this.color && !this.validate) {
        return '<svg><use href="combined.svg#green"></use></svg>';
    }
    if (this.color && this.certain) {
        return '<svg><use href="combined.svg#orange"></use></svg>';
    } else {
        return '<svg><use href="combined.svg#red"></use></svg>';
    }
}

=> 在use > shadow-root 内,没有插入任何内容。

【问题讨论】:

  • 请添加模板的HTML部分
  • @Jankapunkt 完成 - 没什么特别的。

标签: meteor meteor-blaze


【解决方案1】:

有很多错误的可能性,最好发布所有代码。

一种可能性:模板名称与辅助函数声明不匹配。例如

在 html 文件中:

<template name="foo">
...

在js文件中:

Template.bar.helpers({ ....

(这比我承认的更让我痛苦)

我不知道你的意思

=> 在use > shadow-root 内部,没有插入任何内容。

使用 chrome 检查器,您可以选择要检查的元素并查看它是否已真正轻松地呈现在页面中。

【讨论】:

  • 我不认为有任何错误 - 肯定不是模板名称。 SVG sprites 可以在除了助手之外的任何地方,&lt;svg&gt;&lt;use href="combined.svg#filter_sent"&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg&gt;&lt;use href="combined.svg#filter_sent"&gt;*SVGwithPathHere*&lt;/use&gt;&lt;/svg&gt; 中渲染
猜你喜欢
  • 1970-01-01
  • 2012-03-13
  • 2019-04-28
  • 1970-01-01
  • 1970-01-01
  • 2021-12-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多