我想使用UiBinder製作一個GWT小部件。所以,我提出:GWT UiBinder不加載樣式表
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甚至不會要求它。
我錯過了什麼嗎?