我想使用 UiBinder 制作一个 GWT 小部件。所以我做了:
UserPanel.ui.xml 像这样:
<?xml version="1.0" encoding="UTF-8"?>
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field="res" type="com.example.resources.UserPanelResources" />
<g:VerticalPanel styleNames='{res.userpanel.main}'>
...some other widgets go here...
</g:VerticalPanel>
</ui:UiBinder>
UserPanel.css 像这样:
.main {
width: 1000px;
background-color: #f9f9fa;
padding: 15px 10px;
font-family: "Georgia";
}
和 UserPanelResources.java 像:
public interface UserPanelResources extends ClientBundle {
public interface UserPanelCss extends CssResource {
String main();
}
@Source("css/userpanel.css")
UserPanelCss userpanel();
}
所有文件和包都在它们的位置,因为一切都编译得很好。但是当我运行开发模式时,没有应用样式!我尝试了许多不同的方法,但它仍然不起作用。
我注意到的是,在 HTML 中,VerticalPanel 被赋予了被 GWT 混淆的类名,但 CSS 没有发送到浏览器——事实上,GWT 甚至不要求它。
我错过了什么吗?