所以我现在正在尝试做一个基本的流星应用程序..这里有三个文件。
router.js:
Router.configure({
layoutTemplate : 'layout',
loadingTemplate : 'loading',
notFoundTemplate : 'notFound'
});
Router.route("/", {
name : "homeIndex",
data : function() {
return {
message : "Welcome to the Rocket Shop"
}
}
});
的index.html:
<template name="homeIndex">
<h1>{{message}}</h1>
</template>
的layout.html:
<template name="layout">
{{> nav}}
<div class="container">
{{>yield}}
</div><!-- /.container -->
</template>
当我在启动应用程序后转到localhost:3000时,我在浏览器控制台中得到一个很长的堆栈跟踪,并且页面正文无法加载。
22:35:57.444 Exception in callback of async function: MiddlewareStack.prototype.concat@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:303:7
RouteController.prototype._runRoute@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:542:11
Route.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:856:10
Route/route@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:713:5
boundNext@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:425:16
Meteor.bindEnvironment/<@http://localhost:3000/packages/meteor.js?5deab0885176b44ccbbbf0b5101b065971c8f283:999:17
dispatch@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:449:3
RouteController.prototype.dispatch/</<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:393:7
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:349:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:237:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:588:11
RouteController.prototype.dispatch/<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:391:5
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:615:12
RouteController.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:390:3
Router.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1700:3
onLocationChange@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1784:20
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:349:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:237:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?9309a5697855cef52b32921fbc9dcb1017c58b39:588:11
Router.prototype.start@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1777:31
Router/</<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:980:9
.withValue@http://localhost:3000/packages/meteor.js?5deab0885176b44ccbbbf0b5101b065971c8f283:971:17
withoutInvocation/<@http://localhost:3000/packages/meteor.js?5deab0885176b44ccbbbf0b5101b065971c8f283:428:26
Meteor.bindEnvironment/<@http://localhost:3000/packages/meteor.js?5deab0885176b44ccbbbf0b5101b065971c8f283:999:17
onGlobalMessage@http://localhost:3000/packages/meteor.js?5deab0885176b44ccbbbf0b5101b065971c8f283:365:11
1 meteor.js:880:11
有谁可能知道我做错了什么?我只是遵循复数教程并遵循所有指示。
答案 0 :(得分:1)
我在其他铁路由器问题上搜索stackoverflow之后想出了我自己的问题的答案。我不知道为什么它有效,但它解决了这个问题。我所要做的只是运行:
meteor add ejson
我不再得到我的错误。
这是回答我的问题的问题(在我的问题之后发布): Iron:router 1.0.9 Not working
答案 1 :(得分:0)
例外情况并非如此,但我认为有两种可能性:
template
Route.route();
属性
第一个:
Router.route("/", {
name : "homeIndex",
template : "homeIndex",
data : function() {
return {
message : "Welcome to the Rocket Shop"
}
}
});
对于第二个:确保您的router.js
文件位于client/lib/
文件夹中。
另外,请确保iron-router
文件中包含.meteor/packages.js
个包。