Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 流星抛出错误“;延迟回调中出现异常:错误:Can';t调用非函数:[object]";使用flowrouter时_Meteor_Meteor Blaze_Flow Router - Fatal编程技术网

Meteor 流星抛出错误“;延迟回调中出现异常:错误:Can';t调用非函数:[object]";使用flowrouter时

Meteor 流星抛出错误“;延迟回调中出现异常:错误:Can';t调用非函数:[object]";使用flowrouter时,meteor,meteor-blaze,flow-router,Meteor,Meteor Blaze,Flow Router,我是新的流星和以下视频教程。问题是本视频教程没有完全使用ES6。所以没有进出口。但我正在使用es6功能制作我的meteor应用程序,特别是模块的导入和导出 因此,我的项目文件是: /lib/router.js: FlowRouter.route("/", { name: 'home', action(){ BlazeLayout.render("HomeLayout"); } }); FlowRouter.route("/test", { nam

我是新的流星和以下视频教程。问题是本视频教程没有完全使用ES6。所以没有进出口。但我正在使用es6功能制作我的meteor应用程序,特别是模块的导入和导出

因此,我的项目文件是:

/lib/router.js:

FlowRouter.route("/", {
    name: 'home',
    action(){
        BlazeLayout.render("HomeLayout");
    }
});

FlowRouter.route("/test", {
    name: 'test',
    action(){
        BlazeLayout.render("MainLayout",{ main: "TestPage" });
    }
});
/导入/ui/layouts/homeloayout.html:

<template name="HomeLayout">
    <header>
        <h1>My Recipe Book</h1>
        {{> loginButtons}}
    </header>
    <main>
        <div class="billboard">
            <h4>Organise your meals</h4>
        </div>
    </main>
</template>
<template name="MainLayout">
    <header>
        <h1>My Recipe Book</h1>
        {{> loginButtons}}
    </header>
    <main>
        {{ Template.dynamic template=main }}
    </main>
</template>
我正在使用的软件包:

1-布局

双流路由器

3-帐户用户界面

4-帐户密码

现在我的问题是,当我打开localhost:3000时,我看到了预期的家庭布局。但当我转到localhost:3000/test时,我得到以下错误:

Exception in defer callback: Error: Can't call non-function: [object Object]
    at Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:175:13)
    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:106:25)
    at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:110:39)
    at ._render (http://localhost:3000/app/app.js?hash=9b7bb2e95b10af20d691075d259b8ad46bc15c1d:55:22)
    at doRender (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2027:25)
    at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:20
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12)
    at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:29
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12)
    at viewAutorun (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:18)
这在视频教程中效果非常好,视频教程是从图坦卡蒙开始的,它也非常有名。但正如我所说,它是在旧版本的流星,所以没有es6。我使用的meteor版本是1.3.4.1


请帮我解决这个问题,因为我被困在这里,无法取得进展。

您不需要在
main.js
文件中导入和导出。流星为你做了所有的工作。您只需删除
main.js


相反,只需将模板html文件放在
客户机
目录中即可。Meteor将自动检测它们,您的路由器将能够访问它们

哦,找到问题了。{{Template.dynamic Template=main}的把手语法中缺少一个闭合的角括号。它应该是{{>Template.dynamic Template=main}

你添加了
ecmascript
meteor包吗?@pahan-当然是这样我不会正确安排我的项目。我将它们放在导入文件夹中的主要原因是,我可以清楚地将不同文件夹中的不同页面分开。此外,稍后我可能不会使用特定模板,或者我可能不想为特定用户权限导入某些模板。如果需要,可以将模板放在
客户端
中的不同目录中,例如
客户端/视图/布局
客户端/视图/页面
import { Template } from 'meteor/templating';

import '/lib/router.js';

import '/imports/ui/layouts/MainLayout.html';
import '/imports/ui/layouts/HomeLayout.html';
import '/imports/ui/pages/TestPage.html';
Exception in defer callback: Error: Can't call non-function: [object Object]
    at Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:175:13)
    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:106:25)
    at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:110:39)
    at ._render (http://localhost:3000/app/app.js?hash=9b7bb2e95b10af20d691075d259b8ad46bc15c1d:55:22)
    at doRender (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2027:25)
    at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:20
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12)
    at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:29
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12)
    at viewAutorun (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:18)