我有这段代码在Meteor中从数据库创建路由:
if (Meteor.isClient) {
Meteor.subscribe("routes", function() {
Routes.find({}).map(function(route) {
try {
Router.route(route.path, {
name: route.name,
waitOn: function() {
var subscribes = [];
if (typeof route.subscriptions== 'object' &&
route.subscriptions
.length > 0) {
route.subscriptions.forEach(function(subscription) {
subscribes.push(Meteor.subscribe(
subscription));
});
}
return subscribes;
},
action: function() {
this.render(route.template);
}
});
} catch (e) {
console.log("Error: " + e);
}
});
});
}
因此,当我在浏览器中键入来自db的路径的路径时会出现此错误:
糟糕,看起来客户端或服务器上没有路由的网址:“https://localhost:3000/menus。”
我认为是因为此代码在pageloads之后运行。我该如何解决它?