【问题标题】:Iron-router and notFoundTemplateIron-router 和 notFoundTemplate
【发布时间】:2014-08-30 04:06:24
【问题描述】:

这是我的路线:

this.route('showItem', {
  path: '/item/:_id',
  template: 'layout',
  yieldTemplates: {
      'content': {to: 'content'},
      'item_details': {to: 'details'}
  },
  notFoundTemplate: 'notFound',
  data: function () {
      return null; //for test
  }
})

还有notFound模板,很简单:

<template name="notFound">

   Not found!

</template>

我不明白,为什么总是渲染 item_details 而从不渲染 notFound

【问题讨论】:

    标签: meteor iron-router


    【解决方案1】:

    我认为是 Iron-Router 0.7 他们添加了一个要求,您必须打开全局挂钩:

    Router.onBeforeAction("dataNotFound");
    

    这是未找到的模板。 this issue 上有一些关于它的信息。此更改背后的原因是您可以自定义决定是否找到数据的函数。

    【讨论】:

    • 谢谢!现在可以工作了,但是... :-) 是否可以完全渲染notFound 而不是item_details?因为我的content - 带有标记的地图。我不想重绘地图,只有细节部分
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-12
    • 2023-03-12
    • 2017-06-17
    • 1970-01-01
    • 2014-12-15
    • 2016-10-31
    • 2014-05-07
    相关资源
    最近更新 更多