我在lib/server/plugins.js中有一个meteor方法
Meteor.methods({
getPlugins: function() {
return [
{ path: 'test' },
{ path: 'test2' }
]
}
});和我在lib/routes.js中的路由器配置文件
Router.route('/', function() {
this.render('home');
});
Meteor.call('getPlugins', function(e,r) {
if(!e) {
for(var plugin in r) {
function() {
this.route(r[plugin].name);
})
}
} else {
console.log(e);
}
})
var routes = [
{ path: '/test3' },
{ path: '/test4' }
]
for(var i in routes) {
Router.map(function() {
this.route(routes[i].path);
});
}本地变量路由中的所有路由都工作正常,但来自getPlugins iron路由器的路由显示为Oops, looks like there's no route on the client or the server for url: "http://localhost:3000/test2."
发布于 2015-03-10 23:48:26
尝试一下,首先在路由之前添加一个/:
Meteor.methods({
getPlugins: function() {
return [
{ path: '/test' },
{ path: '/test2' }
]
}
});然后将此this.route(r[plugin].name);修改为Router.route(r[plugin].path)
发布于 2015-03-11 01:22:11
多亏了Kyll,我想出了这个解决方案,它确实起到了作用,但我仍然对子路径有疑问
Router.route('/:plugin', function() {
var that = this;
Meteor.call('getPlugins', function(e,r) {
if(!e) {
for(var plugin in r) {
if(r[plugin].path == that.params.plugin) {
that.render(that.params.plugin);
}
}
} else {
console.log(e);
}
})
});https://stackoverflow.com/questions/28967351
复制相似问题