使用Meteor从不同的文件调用函数 [英] call functions from separate files with Meteor

查看:115
本文介绍了使用Meteor从不同的文件调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Meteor中创建一个应用程序,
从我理解的第一次加载的手册中找到
子目录,然后按照字母顺序排列。
我的文件结构就像这样...

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $客户端
/ lib
game.js - >已经开始声明函数makeBoard(){}
/template.js - >函数makeBoard()被调用。

因此显示错误函数makeBoard()不存在,只有当我声明我想调用它的同一个文件。即使当我将文件game.js移动到template.js所在的同一目录时,它也会发生。
我应该如何正确引用Meteor上不同文件中的资源?

code> makeBoard = function(){...} 。



函数foo ){...} 是文件的本地文件,用 var bar = ...

定义的变量

I want to create an application in Meteor, from what I understand the manual it first loads which are in subdirectories, and then follows the alphabetical order. My file structure is like this ...

/server
/lib
/client
    /lib
        game.js -> already starts declaring the function "makeBoard(){}"
    /template.js -> where the function "makeBoard()" is called.

thus appears that the error function "makeBoard()" does not exist, only works if I declare in the same file where I want to call it. Even when I move the file "game.js" to the same directory where "template.js", it happens. How should I correctly make references to resources that are in different files on Meteor?

解决方案

Define the function with makeBoard = function() { ... }.

Functions defined with function foo() { ... } are local to the file, as are variables defined with var bar = ....

这篇关于使用Meteor从不同的文件调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆