[英]Trying to create a Meteor Package
I've been trying to create a Smart Package for the SkelJS framework. 我一直在尝试为SkelJS框架创建智能包。 The file is being loaded by the browser but when I try and access the object it exports it says its
undefined
. 该文件正在由浏览器加载,但是当我尝试访问它导出的对象时,它说它是
undefined
。 I'm using the following code in package.js: 我在package.js中使用以下代码:
Package.describe({
summary: "SkelJS for Meteor"
});
Package.on_use(function (api) {
api.use('jquery', 'client');
api.add_files(['skel.js'], 'client');
api.export('skel', 'client');
});
Also trying to access Package.skeljs.skel
returns undefined
as well. 同样尝试访问
Package.skeljs.skel
也会返回undefined
。
In smart.json I'm using: 在smart.json中,我正在使用:
{
"name": "skeljs",
"description": "SkelJS for Meteor",
"homepage": "",
"author": "Giles Butler (http://giles.io)",
"version": "0.1.0",
"git": ""
}
I know SkelJS has been loaded because it logs to the console no configuration detected, waiting for manual init
but then when I try and run skel.init()
it returns undefined
. 我知道SkelJS已被加载,因为它登录到控制台时
no configuration detected, waiting for manual init
但是当我尝试运行skel.init()
它返回undefined
。
Any help or tips would be really appreciated. 任何帮助或提示将不胜感激。
Thanks 谢谢
Giles 贾尔斯
You also need to modify the first line of skel.min.js
/ skel.js
您还需要修改
skel.min.js
/ skel.js
的第一行
Within packages variable scoping still applies so you have to remove the var
keyword if you want the file to let other files (such as package.js
for api.export
) access its variables. 在package中,变量作用域仍然适用,因此,如果您希望文件允许其他文件(例如
api.export
package.js
)访问其变量,则必须删除var
关键字。
The fix would be to change: 解决方法是更改:
var skel=function() ....
to 至
skel=function() ....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.