究竟如何重写 CssResource

发布于 2024-11-06 13:20:16 字数 1199 浏览 0 评论 0原文

目前我有一个在 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 技术交流群。

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

发布评论

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

评论(1

花之痕靓丽 2024-11-13 13:20:16

我几乎遇到了这个问题。我在阅读GWT 文档中的 @Import 示例< /a> 如下。在您的 MyPinkThemedClientBundle 中,您需要将 css() 方法定义为:

@Source({"main.css", "css/**mainPinkVersion**.css"})
MyCssResource 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:

@Source({"main.css", "css/**mainPinkVersion**.css"})
MyCssResource css();

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.

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