GWT 2 CSS资源如何
我有一个GWT1.7应用程序,我想将其升级到GWT2里程碑2。该应用程序使用2个大的外部CSS文件。在GWT1.7中,我有一个公用文件夹,并将CSS文件放在该文件夹中,我的应用程序编译后运行良好。现在,对于GWT 2,我创建了一个ResourceBundle类,并将所有图像精灵和CSS放在下面:GWT 2 CSS资源如何,gwt,Gwt,我有一个GWT1.7应用程序,我想将其升级到GWT2里程碑2。该应用程序使用2个大的外部CSS文件。在GWT1.7中,我有一个公用文件夹,并将CSS文件放在该文件夹中,我的应用程序编译后运行良好。现在,对于GWT 2,我创建了一个ResourceBundle类,并将所有图像精灵和CSS放在下面: public interface ResourceBundle extends ClientBundle { public static final ResourceBundle INSTANCE
public interface ResourceBundle extends ClientBundle {
public static final ResourceBundle INSTANCE = GWT.create(ResourceBundle.class);
@Source("com/web/tech/public/stylesheet1.css")
public Css stylesheet1();
@Source("com/web/tech/public/stylesheet2.css")
public Css stylesheet2();
@Source("com/docobo/keswick/keswickweb/public/images/organisnew.gif")
public ImageResource add_org();
.....
}
Css类是扩展CssResource的空类:
public interface Css extends CssResource{
}
然后在onModuleLoad()中,我使用:
编译时,出现以下错误:
Rebinding com.docobo.keswick.keswickweb.client.ClientResources.ResourceBundle
Invoking <generate-with class='com.google.gwt.resources.rebind.context.InlineClientBundleGenerator'/>
Creating assignment for gxt_gray()
Replacing CSS class names
[ERROR] The following unobfuscated classes were present in a strict CssResource:
[ERROR] x-tab-scroller-left
[ERROR] x-tab-strip-disabled
[ERROR] ......loads of other styles
Fix by adding String accessor method(s) to the CssResource interface for obfuscated classes, or using an @external declaration for unobfuscated classes.
解决了。
正如Thomas@Google组-->不得将@external置于样式的“上方”
此链接中的示例,css将如下所示:
@external .legacySelectorA, .legacySelectorB;
.obfuscated .legacySelectorA { .... }
.obfuscated .legacySelectorB { .... }
/* @external also accepts tail-globs */
@external .myProject-*;
.myProject-text {}
.myProject-foo {}
尝试使用
@NotStrict
。例如:
@NotStrict
@Source("com/web/tech/public/stylesheet1.css")
public Css stylesheet1();
@NotStrict
是“不建议用于新代码”:
@external .legacySelectorA, .legacySelectorB;
.obfuscated .legacySelectorA { .... }
.obfuscated .legacySelectorB { .... }
/* @external also accepts tail-globs */
@external .myProject-*;
.myProject-text {}
.myProject-foo {}
@NotStrict
@Source("com/web/tech/public/stylesheet1.css")
public Css stylesheet1();