如何在GWT中删除注入的CSS资源?

Pri*_*nce 1 gwt uibinder gwt2 cssresource clientbundle

我想在GWT应用程序中删除注入的CSSResource.

我使用了以下代码 MyClass.INSTANCE.ensureInjected();

我只想在特定页面上使用上面的CSSResource.所以剩下的页面应该按照实际的css/theme来工作.

一旦我注入了它,那么它适用于整个应用程序.我怎么能克服这个?

帮我.

Man*_*ino 6

您可以使用直接StyleInjector实用程序类而不是ensureInjected()方法注入css包

然后,您将获得注入元素的引用,您可以在需要时删除它.

// Equivalent to MyClass.INSTANCE.ensureInjected()
StyleElement e  = StyleInjector.injectStylesheet(MyClass.INSTANCE.css().getText());


// Remove the injected css element
e.removeFromParent();
Run Code Online (Sandbox Code Playgroud)