是否可以在 google web toolkit 中使用 jquery 插件?
有很多优秀的插件可用于各种 UI 小部件,例如日期/时间选择器、可搜索的下拉菜单等。在许多情况下,这些插件还带有自己的 css 样式。我希望能够使用这些插件并在我的 gwt 应用程序中获取它们的值。
Yes .. you can use Javascript libs in GWT project. Simply import it's lib in your html file or GWT.xml. In your module.xml file as below..
<module rename-to='TestingProject'>
<inherits name='com.google.gwt.user.User'/>
<entry-point class='test.Gwt.testingSample.client.TestingProjectEntry'/>
<inherits name="com.google.gwt.user.theme.standard.Standard" />
<source path='client'/>
<source path='shared'/>
<script src="/js/jquery-1.10.min.js"></script>
</module>
And test in your HTML file..
<body>
<center>
<div id= "start"></div>
</center>
<script type="text/javascript">
$(document).ready(function(){
$("div#start").html("<font color = 'green' font-weight = 'bold' size = '12'>
Hello World !</font>");
});
</script>
<body>
Have a useful for you... !
根据经验,您有两种选择。
http://code.google.com/p/gwtquery/
http://code.google.com/p/gwtquery-plugins/
JSNI 文档
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html
恕我直言,最好坚持使用 GwtQuery,因为 jquery 函数几乎可以在 GwtQuery 中逐字使用,并且您可以通过 gwt 编译器编译和优化代码获得额外的性能提升。