如何导入 Gwt-Bootstrap?

问题描述

我将在我的 UiBinder 文件中使用 Gwt-Bootstrap。我导入了这个

xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">

到我的 UIBinder 文件和这个

<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<link rel="stylesheet" href="{your module name}/css/font-awesome-ie7.css">

到我的 Html 文件。但它不起作用。错误

Package com.github.gwtbootstrap.client.ui cannot be 
 resolved

解决方法

GWT-Bootstrap 必须添加到 GWT 项目中。如果您使用的是 Maven,请添加相应的依赖项:

<dependency>
  <groupId>com.github.gwtbootstrap</groupId>
  <artifactId>gwt-bootstrap</artifactId>
  <version>2.3.2.1-SNAPSHOT</version>
</dependency>

然后,在您的 GWT 模块 (.gwt.xml) 中继承 GWT-Bootstrap 模块:

<module>
    <inherits name='com.github.gwtbootstrap.Bootstrap' />
    ...
</module>

但是,请注意 GWT-Bootstrap 已过时且不再维护。我在许多项目中使用 Bootstrap 和 GWT,我相信将它们结合使用的最佳方法是使用 HTML 和 Bootstrap 标准,并将 HTML 元素与 Elemental2 绑定到 GWT。效果很好,没有任何限制,而且是面向未来的。