在GWT 2.0 CssResource中,如何“打印”GWT.getModuleBaseURL()

时间:2011-05-13 13:52:56

标签: gwt gwt2

我有一个引用背景图像的类(我不想升级到使用imagebundles)所以我需要在我的图片网址之前打印“基本模块网址”。我怎样才能做到这一点?

background: #BDE5F8 url("image/info.png") no-repeat 2px center;

2 个答案:

答案 0 :(得分:0)

您总是可以在某处添加静态功能:

public static String getBackgroundUrl(){
     return com.google.gwt.core.client.GWT.getModuleName() + "/images/background.png";
}

在你的CSS中

@eval BG_URL com.yourclass.getBackgroundUrl();

.myBackground { background-url:BG_URL; }

答案 1 :(得分:-1)

在ClientBundle中包含图像真的是要走的路。但话说回来,你已经提到过你不会这样做。

相反,请考虑使用value function获取GWT.getModuleBaseURL()

的值
.something {
    background: #BDE5F8 value('com.google.gwt.core.client.GWT.getModuleBaseURL', '/info.png') no-repeat 2px center;
}