【问题标题】:Any way to pass an element from one context to another?有什么方法可以将元素从一个上下文传递到另一个上下文?
【发布时间】:2014-11-08 07:13:59
【问题描述】:

我有一个看起来像下面这样的流星模板。本质上,我想将一些东西从我的父模板传递给我的孩子。有没有办法做到这一点?

<template name="parent">
Hello my name is {{name}}
{{#each children}}
    {{> child}}
{{/each}}
</template>

<template name="child">
Hello my name is {{child_name}} and my parent's name is [not sure what to do]
</template>

任何帮助将不胜感激!

【问题讨论】:

    标签: meteor meteor-blaze


    【解决方案1】:

    使用点点运算符遍历父视图。

    <template name="parent">
    Hello my name is {{name}}
    {{#each children}}
        {{> child}}
    {{/each}}
    </template>
    
    <template name="child">
    Hello my name is {{child_name}} and my parent's name is {{../name}}
    </template>
    

    See demo heredocumentation here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-07
      • 1970-01-01
      • 1970-01-01
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-24
      相关资源
      最近更新 更多