本文介绍了'jshint':'不要在循环中创建函数'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在循环中使用函数的其他方式是什么?
我得到一个jshint错误,提示'不要在循环中创建函数'。
`
//循环内
google.maps.event.addListener(marker ,'click',function(){
if(this.getAnimation()!== null){
this.setAnimation(null);
> myFunction = function(){};
//循环开始
google.maps.event.addListener(marker,'click',this.myFunction);
Any other way of using function inside a loop?
I get a jshint error saying 'Don't make functions within a loop'. `
//inside loop
google.maps.event.addListener(marker, 'click',function(){
if (this.getAnimation() !== null) {
this.setAnimation(null);
解决方案 Try this code
myFunction = function(){};
//loop starts
google.maps.event.addListener(marker, 'click',this.myFunction);
这篇关于'jshint':'不要在循环中创建函数'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!