如何在 Vaadin Flow 中获取 VerticalLayout 而不是 HorizontalLayout 上的滚动条
这是使用 vaadin starter项目hello world示例。从本质上讲,我想在左侧的verticallayout
中使用滚动条,而不是在整个页面上,如下图所示:
总是出现在右侧。我怀疑这可能与appayout
有关,但我不确定如何调整它,以便在下图中显示的verticallayout
在verticallayout
上。
代码如下:
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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以用滚动器组件包装需要滚动栏的布局。有关更多信息,请参见官方文档 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