流星路由器不呈现模板 [英] Meteor router doesn't render the template
问题描述
我创建了一条路线,并为其指定了通往模板的路径.但是,当我运行该应用程序时,它说没有路线".路由器根本不遵循路径. (我确定安装了路由器软件包,因为如果我不创建并指定任何路由,则在主页上会显示默认信息如何使用路由器)
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');
推荐答案
仅使用代码/标记创建新项目(并添加iron:router)我在浏览器控制台中看到两个错误:
Creating a new project with just the code/markup (and adding iron:router) I see two errors in the browser console:
- 未捕获的错误:没有此类模板:todos
- 异步函数的回调中的异常:ReferenceError:未定义EJSON(被截断)
第一个很简单-添加一个名为todos的模板,或删除包含它的标记.
So the first one is simple - add a template called todos, or remove the markup that includes it.
第二个错误是由iron:router引发的.它必须具有对ejson包的依赖关系,默认情况下它不再包含在流星基础包中.
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
将解决此问题,然后/register路由将起作用.
Will fix this, and the /register route will then work.
这篇关于流星路由器不呈现模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!