Yoa*_*ami 2 java gwt conditional-compilation
有没有办法让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
Run Code Online (Sandbox Code Playgroud)
等等
mar*_*vic 11
是的,当然.这个东西叫做延迟绑定.查看http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html
这是一段摘录
<module>
<!-- ... other configuration omitted ... -->
<!-- Fall through to this rule is the browser isn't IE or Mozilla -->
<replace-with class="com.google.gwt.user.client.ui.impl.PopupImpl">
<when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>
</replace-with>
<!-- Mozilla needs a different implementation due to issue #410 -->
<replace-with class="com.google.gwt.user.client.ui.impl.PopupImplMozilla">
<when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl" />
<any>
<when-property-is name="user.agent" value="gecko"/>
<when-property-is name="user.agent" value="gecko1_8" />
</any>
</replace-with>
<!-- IE has a completely different popup implementation -->
<replace-with class="com.google.gwt.user.client.ui.impl.PopupImplIE6">
<when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>
<when-property-is name="user.agent" value="ie6" />
</replace-with>
</module>
Run Code Online (Sandbox Code Playgroud)
对于其他浏览器,我相信它可以在没有规则下降的情况下工作.我认为规则的下降只是为了加快速度.不要认为这是理所当然的,因为我不是100%肯定.
这来自官方GWT文档.
| 归档时间: |
|
| 查看次数: |
1252 次 |
| 最近记录: |