如何将Iron Router参数传递给Template.myTemplate.rendered
回调函数?以下路由和回调函数对于console.log
都会返回undefined
。
URL
http://localhost:3000/story/1234
Router.js
Router.map( function() {
this.route('story', {
path: '/story/:_id',
template: 'story'
})
})
故事.js
Template.story.rendered = function () {
console.log('params: ', this.params) // undefined
console.log('_id: ', this._id) // undefined
}