console.log() - > console是一个未声明的变量

时间:2016-08-26 22:10:38

标签: javascript console.log undeclared-identifier

我正在编写我的第一个jQuery插件和面向对象编程。我已经习惯了javascript和jQuery,并且在进行调试时总是使用console.log()。但是这次我得到一个错误,console.log()的'console'部分是未声明的,我不能吐出任何信息。我的方法有什么看起来很奇怪或看起来会导致这个奇怪的错误吗?

$.fn.setup = function(map) {
  var coords;

  map_ref = "map[name='"+ map + "']";
  img_ref = "img[usemap='#" + map + "']";
  $(img_ref + ',' + map_ref).wrapAll('<div class="mapContainer"></div>');
  $('.mapContainer').append('<canvas id="canvMap" class="ctxLight"></canvas>');
  $(img_ref).addClass("imgLight");

  $('.mapContainer').css( {
    "position": "relative",
    "display": "inline-block"
  } );
  $('.imgLight').css( {
    "position": "absolute",   // necessery styling for                                                                                                                                                                                      
    "z-index": "1"            // layering image and canvas                                                                                                                                                                                  
  } );
  $('.ctxLight').css( {       //  Other things Setup needs to do:                                                                                                                                                                           
    "position": "relative",   //      - Add data- to area tags for group referencing                                                                                                                                                        
    "z-index": "2",
    "pointerEvents": "none"
  } );

  ctx = document.getElementById('canvMap').getContext('2d');
  $('#canvMap').attr('width', $(this).width());
  $('#canvMap').attr('height', $(this).height());
  $(this).initMap();                                                                                                                                                                                                                      

  for (i = 0; i < $(map_ref + ' > area').length(); i++) {
    obj[i] = new MapArea(calcDimension($(this)), 1, $(this));
    console.log('testing'); //this is the line in question
  }
};

0 个答案:

没有答案