翡翠:括号错误

时间:2014-03-15 13:20:40

标签: node.js pug agents-jade

编译代码时:

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框架

1 个答案:

答案 0 :(得分:0)

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

  • Jade Syntax 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 ()