0

当我编译我的代码时:

script
(function() {
  var uv = document.createElement('script'); 
  uv.type = 'text/javascript'; 
  uv.async = true;
  uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/MY_API_KEY.js';
  var s = document.getElementsByTagName('script')[0]; 
  s.parentNode.insertBefore(uv, s);
});

编译器将错误显示为:

Jade:9
7|    var s = document.getElementsByTagName('script')[0]; 
8|    s.parentNode.insertBefore(uv, s);
9|    });

缺少 ) 在括号中

任何帮助将不胜感激,我不太擅长 Jade 框架

4

1 回答 1

0

在这里,我们最多有 3 个错误:

  • 翡翠语法 x2

    1. 脚本标记前缺少点。

    2. 压痕不好

  • Javascript x1

    1. 该函数永远不会被调用/执行,因为最后缺少 ()。

.script  // the dot
  (function() {    // indent  all the js in the script tag.
    var uv = document.createElement('script'); 
    uv.type = 'text/javascript'; 
    uv.async = true;
    uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/MY_API_KEY.js';
    var s = document.getElementsByTagName('script')[0]; 
    s.parentNode.insertBefore(uv, s);
  })(); // missing ()
于 2014-03-15T14:00:17.123 回答