相关疑难解决方法(0)

在GWT中需要app范围的CSS常量

我想在GWT CssResource中将一些颜色定义为常量,并在整个应用程序中使用这些常量; 但我不知道该怎么做.

我会告诉你我尝试了什么.我创建了一个ClientBundle和一个CssResource,如下所示:

public interface Resources extends ClientBundle {
  public interface MyStyle extends CssResource {
    String JUNGLEGREEN();
    String example();
    ...
  }
  @Source("Resources.css")
  MyStyle css();
}
Run Code Online (Sandbox Code Playgroud)

我在Resources.css中定义了一些常量:

@def JUNGLEGREEN #1F3D0A;
Run Code Online (Sandbox Code Playgroud)

在Resources.css中,我使用这样的常量:

.example { color:JUNGLEGREEN; }
Run Code Online (Sandbox Code Playgroud)

我不知道在其他CSS文件和UiBinder模板中重用这些常量的方法.我想在其他一些UiBinder文件中执行此操作,比如LoginView.ui.xml:

<ui:with field='resources' type='com.example.Resources' />
<ui:style>
  .mainPanel {
    background:{resources.css.JUNGLEGREEN};
    ...
  }
</ui:style>
Run Code Online (Sandbox Code Playgroud)

...但它似乎没有编译.你知道我怎么能实现我的目标吗?

gwt uibinder cssresource

8
推荐指数
1
解决办法
2706
查看次数

标签 统计

cssresource ×1

gwt ×1

uibinder ×1