尝试创建一个流星包 [英] Trying to create a Meteor Package
问题描述
我一直在尝试为 SkelJS 框架创建一个智能包.该文件正在由浏览器加载,但是当我尝试访问它导出的对象时,它说它的 undefined
.我在 package.js 中使用以下代码:
I've been trying to create a Smart Package for the SkelJS framework.
The file is being loaded by the browser but when I try and access the object it exports it says its undefined
. I'm using the following code in 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');
});
尝试访问 Package.skeljs.skel
也会返回 undefined
.
Also trying to access Package.skeljs.skel
returns undefined
as well.
我在 smart.json 中使用:
In smart.json I'm using:
{
"name": "skeljs",
"description": "SkelJS for Meteor",
"homepage": "",
"author": "Giles Butler (http://giles.io)",
"version": "0.1.0",
"git": ""
}
我知道 SkelJS 已被加载,因为它记录到控制台 未检测到配置,等待手动初始化
但是当我尝试运行 skel.init()
它返回 undefined
.
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
.
任何帮助或提示将不胜感激.
Any help or tips would be really appreciated.
谢谢
贾尔斯
推荐答案
你还需要修改第一行skel.min.js
/skel.js
包内变量作用域仍然适用,因此如果您希望文件让其他文件(例如 package.js
用于 api.export
) 访问其变量.
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.
修复方法是更改:
var skel=function() ....
到
skel=function() ....
这篇关于尝试创建一个流星包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!