meteor - 辅助函数中的 SVG 精灵
问题描述
我使用这样的 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 文件中:
<template name="foo">
...
在 .js 文件中:
Template.bar.helpers({ ....
(这比我承认的更频繁地咬我)
我不知道你是什么意思
=> 在
use
>内shadow-root
,没有插入任何内容。
使用 chrome 检查器,您可以选择要检查的元素,并查看它是否已在页面中轻松呈现。
推荐阅读
- android - Android - 如何将数据从服务传递到活动
- java - 在具有 azure 函数 @ServiceBusQueueTrigger 的 java 中,如何获取标签、自定义属性和代理属性?
- karate - 具有数据库查找的空手道自动化框架设计
- python - 修复 UnboundLocalError:在 python/pygame 中的赋值错误之前引用了局部变量 'click'?
- java - 如何在 GetStream 的 getActivities 中过滤特定动词
- php - 提交后一维数组变为多维
- bash - 有没有办法限制 getopts 只能在单个选项上工作?
- java - 在 JAX-RS Rest API 中上传大数据文件
- python - 在 Azure Kubernetes 服务中部署时导入 cv2 错误 - python
- c# - 如何让 ControllerContext 在带有 Hangfire 的 BackgroundJob 中使用 Rotativa 构建 PDF