GWT 2.8 的 JsInteropt 错误

Error with JsInteropt with GWT 2.8

我有这个class:

package br.com.frame.client.teste;
@JsType
public class TesteJsInteropt {

public int b = 5;
}

和我的代码 JavaScript of head html

<script type="text/javascript">
var a = new br.com.frame.client.teste.TesteJsInteropt();
alert(a.b);
</script>

执行项目时,我在控制台中收到此错误 chrome:

Uncaught ReferenceError: br is not defined

导出似乎无法正常工作。您应该检查 -generateJsInteropExports 标志是否已启用(如果此标志未启用,则忽略导出)。 另外,请注意 GWT 脚本加载的异步特性;您上面的代码可能无法运行,因为在您执行 new br.com.frame.client.teste.TesteJsInteropt(); 时,GWT 应用程序尚未完全加载。

一个可能的解决方案是在应用程序完成加载时从您的应用程序入口点调用本机 JS 回调。