Meteor 动态 url 显式模板查找路径
Meteor dynamic url explicit template finding path instead
我有一个明确设置了模板的动态 Iron 路由,但是 Iron 路由器尝试渲染路径而不是模板。
http://localhost:3000/blog/example-post
找不到名为 "Blog:permalink" 或 "blog:permalink" 的模板。你确定是你定义的吗?
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 });
}
})
我有一个明确设置了模板的动态 Iron 路由,但是 Iron 路由器尝试渲染路径而不是模板。
http://localhost:3000/blog/example-post
找不到名为 "Blog:permalink" 或 "blog:permalink" 的模板。你确定是你定义的吗?
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 });
}
})