流星嵌套视图和产量

Meteor nested views and yields

我正在设置我未来的 meteor 应用程序的基本结构,我正在使用 meteor 和 angular。想将 iron router 与 ui router 结合使用,但效果很差。所以现在我又回到香草流星来解决路由问题,任务是拥有标准的多页站点,但其中一个页面是一个复杂的面板,有自己的子页面。

所以我有一个带有 >yield 的全局布局,所有内容都在那里呈现,现在这个 dasboard 页面也呈现到这个 yield 中,但它必须有自己的 yield。如何设置路由器使其正常工作?如何准备模板?

将您的首选路由器用于顶级路由,然后对于要插入仪表板的模板使用 Template.dynamic

{{> Template.dynamic template=template [data=data] }}

  • Choose a template to include dynamically, by name.

Arguments

  • template String The name of the template to include.

  • data Object Optional. The data context in which to include the template.

Template.dynamic allows you to include a template by name, where the name may be calculated by a helper and may change reactively. The data argument is optional, and if it is omitted, the current data context is used.

For example, if there is a template named "foo", {{> Template.dynamic template="foo"}} is equivalent to {{> foo}}.

Here is a tutorial.