究竟如何重写 CssResource
目前我有一个在 gwt 中使用 CssResource 的应用程序,如下所示...
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/two.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/main.css")
MyCssResource css();
}
然后是 CssResource 接口
interface MyCssResource extends CssResource{
String someStyleThatNeverChanges();
String someStyleThatChangesDependingOnTheClient();
}
如果我重写 MyClientBundle 来创建名为 MyPinkThemedClientBundle 的接口
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/**twoPinkVersion**.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/**mainPinkVersion**.css")
MyPinkCssResource css();
}
那么当然 MyPinkCssResource 扩展了 MyCssResource
interface MyPinkCssResource extends MyCssResource{
}
我遇到的问题是,当我尝试编译 GWT 编译器时抱怨“css/mainPinkVersion.css”缺少样式名称“someStyleThatNeverChanges”。我本以为 cssresource 接口会继承其超类的支持 css 文件。如果不是这种情况,是否可以实现扩展 CssResource 并仅覆盖您关心的类但使用超类的支持 .css 文件的效果?
Currently I have an application using CssResource in gwt like this...
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/two.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/main.css")
MyCssResource css();
}
And then the CssResource interface
interface MyCssResource extends CssResource{
String someStyleThatNeverChanges();
String someStyleThatChangesDependingOnTheClient();
}
If I override MyClientBundle to create and interface called MyPinkThemedClientBundle
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/**twoPinkVersion**.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/**mainPinkVersion**.css")
MyPinkCssResource css();
}
Then of course MyPinkCssResource extends MyCssResource
interface MyPinkCssResource extends MyCssResource{
}
The problem I have is that when I try to compile this the GWT compiler complains that "css/mainPinkVersion.css" is missing the style name "someStyleThatNeverChanges". I would have thought that a cssresource interface would inherit the backing css file of its super class. If this is not the case, is it possible to achieve the effect of being able to extend a CssResource and override just the classes you care about but otherwise use the super-classes' backing .css file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我几乎遇到了这个问题。我在阅读GWT 文档中的 @Import 示例< /a> 如下。在您的
MyPinkThemedClientBundle
中,您需要将 css() 方法定义为:如果您只是覆盖已经定义的 CSS 条目,而不是创建任何需要在代码中访问的新条目,那么您不需要MyPinkCssResource 类型。
I ran into almost exactly this issue. The solution I came up with after reading the @Import example in the GWT documentation is as follows. In your
MyPinkThemedClientBundle
you need to define css() method as:If you are just overriding already defined CSS entries, and not creating any new ones that need to be accessed in your code then you won't need the MyPinkCssResource type.