簡體   English   中英

流星動態url顯式模板查找路徑

[英]Meteor dynamic url explicit template finding path instead

我有一個動態設置了模板的動態鐵路線,但是鐵路由器試圖渲染路徑而不是模板。

http:// localhost:3000 / blog / example-post

找不到名為“博客:永久鏈接”或“博客:永久鏈接”的模板。 確定要定義嗎?

Router.route('/blog/:permalink'), {
  template: 'blogPost',
  name: 'blogPost',
  path: '/blog/:permalink',
  data: function () {
    return Blogs.findOne({ permalink: this.params.permalink, published: true });
  }
}

Router.route('blog'), {
  path: '/blog',
  waitOn: function () {
    return [
      Meteor.subscribe('blogs')
    ]
  }
}

您關閉路線)而無需添加有選項的對象(見,) )。 這就是為什么iron:router嘗試從路徑生成模板名稱的原因:

Router.route('/blog/:permalink'), {

應該:

Router.route('/blog/:permalink', {
  template: 'blogPost',
  name: 'blogPost',
  path: '/blog/:permalink',
  data: function () {
    return Blogs.findOne({ permalink: this.params.permalink, published: true });
  }
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM