我正在对滑块问题进行故障排除,但是,我不知道javascript那么好,我已经隔离了负责滑块功能的.js文件,还有一个我要解雇的destroy函数关闭,代码看起来像这样
(function ($) {
$.pixelentity = $.pixelentity || {version: '1.0.0'};
$.pixelentity.peBackgroundSlider = {
conf: {
api: false,
wait: false
},
paused: false
};
function PeBackgroundSlider(target, conf) {
...
function destroy() {
prevColor = currentColor = currentBW = jwindow = jthis = undefined;
target.data("peBackgroundSlider", null);
target = undefined;
}
}
如何在这种情况下解除销毁功能?
答案 0 :(得分:2)
你现在不能。
要调用它,您必须按如下方式“导出”它:
function PeBackgroundSlider(target, conf) {
...
function destroy() {
prevColor = currentColor = currentBW = jwindow = jthis = undefined;
target.data("peBackgroundSlider", null);
target = undefined;
}
return { "destroy": destroy };
}
来自来电者:
var ret = PeBackgroundSlider();
现在你可以做到:
ret.destroy();
或者,更简洁:
return destroy;
和
innerDestroy = PeBackgroundSlider();
最后:
innerDestroy();