为什么 Telescope 中的 Iron-Router 无法识别传递的 _id 参数?
Why Iron-Router in Telescope is not recognizing the _id parameter that is passed?
我正在尝试响应一个事件,Telescope 转到 post next/previous。
var y = Router.current().data().postedAt;
var nex = Posts.find({postedAt:{$gt:y}}, {sort: {postedAt:1}, limit:1});
nex.forEach(function(nex){ vai = nex._id;});
Router.go('post_page', vai, {_id:vai});
问题是当我尝试将 nex._id
传递给路由器时。控制台上显示此消息:
Error: Missing required parameters on path "/ posts /: _ id". The
missing params are: ["_id"]. The params object passed in was:
"erhqpuXxXgk9EA4Gg".
_id
正确通过,但未被识别。谢谢!
希望你的路线如下:
Router.route('/posts/:_id', function () {
this.render('Post');
}, {
name: 'post_page'
});
您的 Router.go 方法应该是:
Router.go('post_page', {_id: vai});
我可以让它发挥作用。看看如何:
var y = Router.current().data().postedAt;
var nex = Posts.find({postedAt:{$gt:y}}, {sort: {postedAt: 1}, limit:1} );
nex.forEach(function(nex){ _id = nex._id;});
Router.go('post_page', {_id:this._id});
我正在尝试响应一个事件,Telescope 转到 post next/previous。
var y = Router.current().data().postedAt;
var nex = Posts.find({postedAt:{$gt:y}}, {sort: {postedAt:1}, limit:1});
nex.forEach(function(nex){ vai = nex._id;});
Router.go('post_page', vai, {_id:vai});
问题是当我尝试将 nex._id
传递给路由器时。控制台上显示此消息:
Error: Missing required parameters on path "/ posts /: _ id". The missing params are: ["_id"]. The params object passed in was: "erhqpuXxXgk9EA4Gg".
_id
正确通过,但未被识别。谢谢!
希望你的路线如下:
Router.route('/posts/:_id', function () {
this.render('Post');
}, {
name: 'post_page'
});
您的 Router.go 方法应该是:
Router.go('post_page', {_id: vai});
我可以让它发挥作用。看看如何:
var y = Router.current().data().postedAt;
var nex = Posts.find({postedAt:{$gt:y}}, {sort: {postedAt: 1}, limit:1} );
nex.forEach(function(nex){ _id = nex._id;});
Router.go('post_page', {_id:this._id});