使用Google Analytics和Facebook Pixel关闭编译器警告

时间:2017-03-31 01:59:39

标签: javascript google-closure-compiler

我有一个看起来像这样的函数:

        WARNING - Function function: called with 5 argument(s). 
        Function requires at least 7 argument(s) and no more than 7 argument(s).
        (function (i, s, o, g, r, a, m) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     ClosureCompiler/initialjxaz.js:512: WARNING - Suspicious code. The result of 
        the 'not' operator is not being used. !function (f, b, e, v, n, t, s) { 
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ClosureCompiler/initialjxaz.js:512: 
        WARNING - Function function: called with 4 argument(s). Function requires at 
least 7 argument(s) and no more than 7 argument(s). 
        !function (f, b, e, v, n, t, s) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ^^^^ 0 error(s), 3 warning(s)

问题在于,当我在Closure Compiler高级模式下运行时,我得到3个警告,因为参数的数量不匹配。以下是警告:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
 RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R=301]

我该怎么做才能解决它?

1 个答案:

答案 0 :(得分:1)

您可以安全地忽略这些警告。代码有额外的函数参数,没有使用,所以Closure-compiler是警告。如果参数被标记为可选或具有默认值,则编译器不会发出警告。

我也不知道为什么他们在该函数前使用!运算符。看起来他们正在使用它来防止没有分号的连接文件 - 但我只是期望他们使用;