问题
I created a route and gave it a path to a template. But when I run the application, it says that 'there is no route'. Router simply doesn't follow the path. (I am sure the router package is installed because if I don't create and specify any route, on the main page appears the default message how to use a router)
HTML:
<head>
<title>todos</title>
</head>
<body>
{{>todos}}
</body>
<template name="register">
<h2>Register</h2>
</template>
route.js:
Router.route('/register');
回答1:
Creating a new project with just the code/markup (and adding iron:router) I see two errors in the browser console:
- Uncaught Error: No such template: todos
- Exception in callback of async function: ReferenceError: EJSON is not defined (truncated)
So the first one is simple - add a template called todos, or remove the markup that includes it.
And the second error is being thrown by iron:router. It must have a dependency on the ejson package that is no longer included by default in the meteor base packages.
meteor add ejson
Will fix this, and the /register route will then work.
来源:https://stackoverflow.com/questions/32912767/meteor-router-doesnt-render-the-template