ui:with,样式未显示

发布于 2024-10-03 01:25:15 字数 1476 浏览 6 评论 0原文

我想使用 .

我可以看到 css 类名被混淆了,但是类定义 当我检查 firefox / chrome 中的元素时,没有显示。 这是我的代码。谁能建议我错过了什么?谢谢。

Style.css

.nameSpan {  color: #3E6D8E; background-color: #E0EAF1;} 

Resources.java

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

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> 

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)); 
        } 

I would like to share a CSS across multiple widgets using .

I can see that css class name are obfuscated but the class definition
is not showing up when I inspect the element in firefox / chrome.
Here're my codes. Can anyone suggest what am I missing? Thanks.

Style.css

.nameSpan {  color: #3E6D8E; background-color: #E0EAF1;} 

Resources.java

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

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> 

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)); 
        } 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日落 2024-10-10 01:25:15

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

You have to use res.style().ensureInjected()

蝶…霜飞 2024-10-10 01:25:15

您需要在某处分配样式(styleName 属性)。例如:

<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.nameSpan}">kevin</g:InlineLabel>
        </div> 
    </g:HTMLPanel> 
</ui:UiBinder>

您声明的属性 ui:field 未设置 css 样式。它定义了要在 uibinder 类中填充的属性。请参阅 GWT 文档获取一些指导。

You need to assign the style (styleName attribute) somewhere. For example:

<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.nameSpan}">kevin</g:InlineLabel>
        </div> 
    </g:HTMLPanel> 
</ui:UiBinder>

The attribute ui:field you've declared does not set the css style. It defines the attribute that is to be filled in in your uibinder class. See the GWT doc for some guidance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文