我有这门课:
package br.com.frame.client.teste;
@JsType
public class TesteJsInteropt {
public int b = 5;
}
和我的 head html 代码 JavaScript
<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 应用程序尚未完全加载。
一个可能的解决方案是在完成加载时从应用程序入口点调用 native JS 回调。
关于javascript - GWT 2.8 的 JsInteropt 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43146294/