Vaadin 10 对话框不显示

Vaadin 10 Dialog doesn't show up

我看不到我的 Vaadin Dialog,我正在尝试添加一个简单的 Vertical Layout
这是我的代码:

Dialog d = new Dialog(new Label("Simple label"));
d.setCloseOnEsc(false);
d.setCloseOnOutsideClick(false);

Button cancelBtn = new Button("Cancel", event ->  {
    d.close();
});

d.add(cancelBtn);
add(d);

我希望有人能帮助我:)

Dialog::open

A​​ Dialog is a specific component - it is not normally rendered within the given container, but opens as a popup. Therefore, it has special semantics to make it to render - after creating a dialog, you have to call dialog.open() 使其显示。

这也不是 Vaadin 特有的 - 在许多框架中,对话框(和其他弹出窗口)以特殊方式显示 - 这有点像一种模式。