【问题标题】:Data context lost in special case with blaze rendering在火焰渲染的特殊情况下丢失数据上下文
【发布时间】:2014-04-11 18:06:17
【问题描述】:

我正在尝试将我的应用程序从流星 0.7.x 更新到 0.8 我解决了很多符合 blaze 规范的问题,但在一些特殊情况下我仍然遇到一些问题,即在对这样的帮助程序的调用中数据上下文丢失 {{#if myHelper}}{{lostData}}{{/if}}

我做了一个示例来解释问题并让每个人都可以重现它:

open a browser and the console
then go to http://bugdatacontext.meteor.com/
have a look a the console before and after should be the same, but it's not.

源代码在这里:https://github.com/Rebolon/meteor-renderDataContext-bug

[原帖] 我正在尝试将我的应用程序从流星 0.7.x 更新到 0.8 我解决了很多符合 blaze 规范的问题,但我仍然对应该是动态的 html 属性有一些问题。

例如,我必须呈现一些网址:

<img src="/path/to/image/{{_id}}" />

使用 Sparks 效果很好,但是使用 blaze {{_id}} 在 html 属性中使用时只是 null,而在这样的 html 标记中使用时可以:

<span>{{_id}}</span>

动态生成我的网址的正确方法是什么? 谢谢

经过进一步调查,问题似乎与属性无关,因为如果我在 img 标签之前使用 {{_id}},它会显示 _id。我仍在寻找问题;如果解决方案对每个人都感兴趣,我会提出问题,否则我会删除它。 感谢cmets

【问题讨论】:

  • 我刚刚对此进行了测试,Blaze 允许渲染 和 {{_id}}

标签: meteor meteor-blaze


【解决方案1】:

在流星 github 项目中创建问题后,我得到了这个答案:

UI.toHTML(template.extend({"data": data}));

instead of

UI.renderWithData(template, data).render().toHTML();

来源:https://github.com/meteor/meteor/issues/2044

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 2018-11-19
    • 2016-07-22
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多