这是代码。
(函数($){ $.fn.testfunc = 函数() { this.init = 函数() { setInterval(this.func1(), 1000); }; this.func1 = 函数() { 控制台.log('func1'); this.func2(); }; this.func2 = 函数() { 控制台.log('func2'); //一些代码 }; 返回 this.init(); } })(jQuery);
*当我使用括号时,第一个和第二个方法运行但第一个方法只调用一次。
*当我不使用括号时,第一种方法在间隔中运行得很好,但它不能/不能调用第二种方法。
我应该带什么去?带括号还是不带括号?我需要在间隔内运行第一种方法,但也需要调用第二种方法。