Trying to create a Meteor Package

久未见 提交于 2019-12-12 04:16:26

问题


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');
});

Also trying to access Package.skeljs.skel returns undefined as well.

In smart.json I'm using:

{
  "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.

Any help or tips would be really appreciated.

Thanks

Giles


回答1:


You also need to modify the first line of 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.

The fix would be to change:

var skel=function() ....

to

skel=function() ....


来源:https://stackoverflow.com/questions/21079223/trying-to-create-a-meteor-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!