所以我现在正在尝试做一个基本的 meteor 应用程序..这是三个文件。
路由器.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>
布局.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
有人知道我做错了什么吗?我只是遵循pluralsight 教程并遵循了所有指示。
最佳答案
在 stackoverflow 搜索其他 Iron-router 问题后,我找到了自己问题的答案。我不知道它为什么有效,但它解决了问题。我所要做的就是运行:
meteor add ejson
我不再犯错误了。
这是回答我的问题的问题(在我的问题之后发布): Iron:router 1.0.9 Not working
关于javascript - 如何使用yield和Iron-router?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32731824/