如何在 Vaadin Flow 中获取 VerticalLayout 而不是 Horizo​​ntalLayout 上的滚动条

发布于 01-20 22:33 字数 800 浏览 6 评论 0原文

这是使用 vaadin starter项目hello world示例。从本质上讲,我想在左侧的verticallayout中使用滚动条,而不是在整个页面上,如下图所示:

​总是出现在右侧。我怀疑这可能与appayout有关,但我不确定如何调整它,以便在下图中显示的verticallayoutverticallayout上。

代码如下:

add(getHelloVerticalLayout(), new HorizontalLayout(new Button("Simple")));

其中gethelloverticallayout()仅包含一堆Hello按钮,因此它足够大,可以在网页上生成滚动条。

private VerticalLayout getHelloVerticalLayout() {
    List<Button> buttons = new ArrayList<>();
    for(int x=0; x<=50; x++)
        buttons.add(new Button("Hello"));
    return new VerticalLayout(buttons.toArray(Button[]::new));
}

This is using the Vaadin starter project Hello World example. In essence I want to have the scrollbar in the VerticalLayout on the left rather than on the whole page as shown in the image below:

enter image description here

However no matter what I do the scrollbar always appears on the right side. I suspect this may have to do with the AppLayout but I'm not sure how to adjust it so that the scrollbar is on the VerticalLayout shown in the diagram below.

The code is as follows:

add(getHelloVerticalLayout(), new HorizontalLayout(new Button("Simple")));

Where getHelloVerticalLayout() consists of just a bunch of Hello buttons so that it's large enough to generate a scrollbar on the webpage.

private VerticalLayout getHelloVerticalLayout() {
    List<Button> buttons = new ArrayList<>();
    for(int x=0; x<=50; x++)
        buttons.add(new Button("Hello"));
    return new VerticalLayout(buttons.toArray(Button[]::new));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

最初的梦 2025-01-27 22:33:04

您可以用滚动器组件包装需要滚动栏的布局。有关更多信息,请参见官方文档 https://vaadin.com/docs/docs/docs/latest/latest/latest /DS/组件/滚动器

You can wrap your layout, which needs a scrollbar, with the Scroller component. See the official docs for more information and example https://vaadin.com/docs/latest/ds/components/scroller

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