我有一个现有的应用程序(用 WebGuiToolkit.org 编写),我正在尝试在其中嵌入 Vaadin Flow 页面。
我看过 Vaadin 8 的几个指南,例如
- https://vaadin.com/learn/training/embedding-vaadin https://vaadin.com/learn/training/embedding-vaadin
但没有 Vaadin 14 的指南或帮助。
将 Vaadin 集成到另一个页面需要什么?可以用IFRAME来做吗? Vaadin 也可以在没有 iframe 的同一个 HTML 页面上使用吗?
感谢您的任何提示。
您可以通过使用 iframe 来做到这一点,是的 - 这应该只是标准的 iframe 用法。如果您想在没有 iframe 的情况下在页面内插入 Vaadin 14 应用程序,您可以导出 Web 组件,这确实会在一定程度上限制功能 - 本质上,您需要放弃使用 @Routes(因为 Vaadin 不再控制页面的顶级导航)。这里有一个导出 Web 组件的教程:https://vaadin.com/docs/v14/flow/integrations/embedding/tutorial-webcomponent-exporter https://vaadin.com/docs/v14/flow/integrations/embedding/tutorial-webcomponent-exporter
本质上,您需要创建一个新类,使用要导出的组件的通用类型来扩展 WebComponentExporter,如下所示:
public class LoginFormExporter
extends WebComponentExporter<LoginForm> {
public LoginFormExporter() {
super("login-form"); // you need to call the super constructor with a tag name
}
@Override
protected void configureInstance(
WebComponent<LoginForm> webComponent,
LoginForm form) {
// add initial configuration actions here
}
您还需要加载自定义组件的 JavaScript 文件以及(可能的)polyfill,然后您可以使用您的<custom-tag>
(or <login-form>
,在上面的示例中)在任何网页内。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)