GWT - 基于浏览器的条件编译
有没有办法告诉 GWT 针对每个目标浏览器编译不同的 Java 代码?
GWT 现在为每个目标浏览器创建不同的脚本,所有脚本均由同一源文件生成。然而,当在不同浏览器中使用非标准功能时(例如,将文件拖放到浏览器中),不同浏览器之间的支持差异很大,需要编写不同的代码。
有没有类似之类的
// if IE
.. some Java code to compile into the IE script
// else if chrome
.. some Java code to compile into the chrome script
东西
is there a way to tell GWT to compile different Java code per target browser?
GWT today creates a different script per target browser, all generated from the same source file. However, when working with non-standard features in different browsers (for example, file drag and drop into the browser), the support is quite different between different browsers, requiring to write different code.
Is there something like
// if IE
.. some Java code to compile into the IE script
// else if chrome
.. some Java code to compile into the chrome script
etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,当然。这就是所谓的延迟绑定。请查看 http://code.google.com/webtoolkit/doc/latest/ DevGuideCodingBasicsDeferred.html
这是摘录
对于其他浏览器,我相信它可以在没有失败规则的情况下工作。我认为失败规则的存在只是为了加快事情的进展。不要认为这是理所当然的,因为我不是 100% 确定。
这是来自 GWT 官方文档。
Yes, off course. The thing is called deferred binding. Check out http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html
Here's an excerpt
For the other browsers, I believe it would work without the fall through rule. I think the fall through rule is here just to speed up the things. Don't take this for granted, as I am not 100% sure.
This is from the official GWT documentation.