Google Closure编译器解析错误

时间:2012-07-11 18:41:32

标签: google-closure-compiler

  

可能重复:
  Partially skip sections with Google Closure Compiler

我从编译器中收到以下错误:

Number of errors: 2

JSC_PARSE_ERROR: Parse error. syntax error at line 17 character 18
window.location = <?php echo $this->baseUrl(); ?>"/";
                  ^
JSC_PARSE_ERROR: Parse error. syntax error at line 17 character 47
window.location = <?php echo $this->baseUrl(); ?>"/";
                                               ^

它似乎不喜欢(php)语法。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

用字符串隔离代码:

window.location = eval("<?php echo $this->baseUrl(); ?>") + "/";

这是一个类似的问题:

https://code.google.com/p/closure-compiler/wiki/UsingConditionalCommentWithClosureCompiler