简体   繁体   English

为什么JSLint表示此jQuery中缺少分号?

[英]Why does JSLint say there is a missing semicolon in this jQuery?

Here are some JSLint results: 这是一些JSLint结果:

 1  finaffJS.module('custom_ribbon_buttons', ['jQuery'], function ($) {
 2      var my = {};
 3  
 4      my.insertLightBoxCloseDialog = function () {
 5          var url = $('#finaff-insert-lightbox-image-url').val();
 6          if (url) {
 7              var buttonHtml = '<a class="finaff-lightbox-link" href="' + encodeURI(url) + '"><div class="FinAff_View_Image_Button_Sprites FinAff_View_Image_Button">&#160;</div></a>';
 8              SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, buttonHtml);
 9          } else {
10              $('#finaff-insert-lightbox-image-url-flash').text('Need a URL');
11          }
12      }
13  
14      my.insertLightBoxClicked = function () {
    =^
    lint warning: missing semicolon

Where is the supposed missing semicolon? 所谓的缺少分号在哪里?

Or why is JSLint confused? 还是为什么JSLint感到困惑?

You miss semicolon in line 12: 您会在第12行中错过分号:

 4      my.insertLightBoxCloseDialog = function () {
 5          var url = $('#finaff-insert-lightbox-image-url').val();
 6          if (url) {
 7              var buttonHtml = '<a class="finaff-lightbox-link" href="' + encodeURI(url) + '"><div class="FinAff_View_Image_Button_Sprites FinAff_View_Image_Button">&#160;</div></a>';
 8              SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, buttonHtml);
 9          } else {
10              $('#finaff-insert-lightbox-image-url-flash').text('Need a URL');
11          }
12      };

Take a look at the line 2, you are declaring a variable with a {} , and you put a semicolon. 看一下第2行,您使用{}声明了一个变量,并放入了分号。 insertLightBoxCloseDialog also needs it, is the same. insertLightBoxCloseDialog也需要它,是一样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM