ui:有,风格没有出现

Yau*_*ung 3 gwt uibinder

我想使用多个小部件共享一个CSS.

我可以看到css类名称被混淆,但是当我在firefox/chrome中检查元素时,类定义没有显示出来.这是我的代码.任何人都可以建议我错过了什么?谢谢.

style.css文件

.nameSpan {  color: #3E6D8E; background-color: #E0EAF1;} 
Run Code Online (Sandbox Code Playgroud)

Resources.java

public interface Resources extends ClientBundle { 
  @Source("Style.css") 
  Style style(); 
  public interface Style extends CssResource { 
    String nameSpan(); 
  } 
} 
Run Code Online (Sandbox Code Playgroud)

uibinder.ui.xml

<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.my.app.widgets.logoname.Resources'/> 
  <g:HTMLPanel> 
      <div> 
        Well hello there 
        <g:InlineLabel ui:field='nameSpan' styleName="res.style.nameSpan">kevin</g:InlineLabel>
      </div> 
  </g:HTMLPanel> 
</ui:UiBinder> 
Run Code Online (Sandbox Code Playgroud)

uibinder.class

public class uibinder extends Composite { 
        private static uibinderUiBinder uiBinder =     GWT.create(uibinderUiBinder.class); 
        interface uibinderUiBinder extends UiBinder<Widget, uibinder> {} 
        @UiField(provided = true)  final Resources res;  // the style doesn't show no matter provided=true is declared or not. 
        public uibinder(Resources res) { 
                res = GWT.create(Resources.class); 
                initWidget(uiBinder.createAndBindUi(this)); 
        } 
Run Code Online (Sandbox Code Playgroud)

小智 7

你必须使用 res.style().ensureInjected()