使用 @sprite 从外部 CSS 文件附加 ImageResource
我试图在 GWT2.2 项目中一起使用 CssResource 和 ImageResource 。
CssResource 和混淆工作正常,但我在访问图像时遇到问题。
我已经可以通过 ImageResource 直接从 ui.xml 文件访问图像,方法如下:
<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>
<g:Image resource="{myResource.image}"/>
但是我无法使用 @sprite 从外部 .css 文件中附加 ImageResource。
我有以下接口:
public interface ResourceBundle extends ClientBundle {
ResourceBundle INSTANCE = GWT.create (ResourceBundle.class);
@Source("com/example/client/resource/images/image.png")
ImageResource image();
@Source("com/example/client/resource/css/mystyle.css")
MyCssResource myCssResource();
}
public interface MyCssResource extends CssResource {
String className();
}
当我将精灵添加到 css 文件时,
@sprite .className {
gwt-image: 'image';
}
我收到以下错误消息:
[ERROR] - Unable to find ImageResource method value("image") in
com.example.client.views.MyView_BinderImpl_GenBundle : Could not find
no-arg method named image in type com.example.views.MyView_BinderImpl_GenBundle
I'm trying to use CssResource and ImageResource together in a GWT2.2 project.
CssResource and obfuscation are working properly, but I'm having problems accessing images.
I already can access the images through ImageResource directly from the ui.xml files in the following way:
<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>
<g:Image resource="{myResource.image}"/>
But I cannot attach ImageResource from within external .css files using @sprite.
I have the following interfaces:
public interface ResourceBundle extends ClientBundle {
ResourceBundle INSTANCE = GWT.create (ResourceBundle.class);
@Source("com/example/client/resource/images/image.png")
ImageResource image();
@Source("com/example/client/resource/css/mystyle.css")
MyCssResource myCssResource();
}
public interface MyCssResource extends CssResource {
String className();
}
And when I add the sprite to the css file,
@sprite .className {
gwt-image: 'image';
}
I got the following error message:
[ERROR] - Unable to find ImageResource method value("image") in
com.example.client.views.MyView_BinderImpl_GenBundle : Could not find
no-arg method named image in type com.example.views.MyView_BinderImpl_GenBundle
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 UiBinder 模板访问您的样式,如下所示:
You can access your styles from UiBinder templates as follows: