我有这个代码:
(function() {
function App(elements, options) {
if (!this instanceof App) return new App(elements, options);
var that = this;
return this;
}
window.App = App;
})();
App(document.querySelectorAll('.Slider-slide'), {
interval: 5000
});
我的问题是,它永远不会创建 的新实例App
,因此,this
更进一步的代码始终是Window
对象,知道为什么吗?