因此,我正在使用webpack创建自己的js类来打包我的客户端js,并且我需要使用这个"soundManager“对象,它是我包含在页面上的第三方库。SoundManager实际上生活在window.soundManager上...我的问题是如何在我的SoundLoader类中访问window.soundManager上的这个对象?
/* global soundManager */
'use strict';
var debug = require('debug')('core:SoundLoader');
function SoundLoader() {
this.$sm = soundManager;
}
SoundLoader.prototype.init = function(readyCallback, timeoutCallback) {
this.$sm.setup({
url: '/bower_components/soundmanager2/swf/soundmanager2_flash9.swf',
onready: function() {
if (readyCallback) {
readyCallback();
}
},
ontimeout: function() {
if (timeoutCallback) {
timeoutCallback();
}
}
});
};
module.exports = new SoundLoader();任何帮助都将不胜感激!
谢谢!
发布于 2015-05-09 02:15:48
假设你的项目中有package.json,你可以这样做:
npm i scottschiller/SoundManager2 --save.为了安全起见,您可能应该使用散列语法(#tagname).var soundManager = require('SoundManager2').soundManager;指向代码中的某个特定标记。这将为您提供您要查找的对象。我希望这能帮到你。
https://stackoverflow.com/questions/28575708
复制相似问题