使用 Vaadin 14.1.19 和 Vaadin“我的入门项目”-项目我试图创建一个多行 TextArea。乍一看它工作正常,但在调整 TextArea 大小时,它不适应行数。这是我的代码:
package com.packagename.myapp;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;
@Route(layout = DesktopLayout.class)
@PWA(name = "Project Base for Vaadin Flow with Spring", shortName = "Project Base")
public class MainView extends VerticalLayout {
public MainView(@Autowired MessageBean bean) {
String loremIpsum = "Lorem ipsum dolor sit amet, [....].";
TextArea readOnlyTA = new TextArea();
readOnlyTA.setLabel("Read-only");
readOnlyTA.setWidth("1500px");
readOnlyTA.setMaxWidth("80vw");
readOnlyTA.setValue(loremIpsum);
readOnlyTA.setReadOnly(true);
add(readOnlyTA);
TextArea readWriteTA = new TextArea();
readWriteTA.setLabel("normal");
readWriteTA.setWidth("1500px");
readWriteTA.setMaxWidth("80vw");
readWriteTA.setValue(loremIpsum);
add(readWriteTA);
Div readOnlyDiv = new Div();
readOnlyDiv.setWidth("1500px");
readOnlyDiv.setMaxWidth("80vw");
readOnlyDiv.add(loremIpsum);
add(readOnlyDiv);
}
}
当我用一个宽阔的窗口打开视图时,它看起来像这样很好:
当我调整窗口大小时,它看起来不像这样,因为只有文本的开头是可读的。我什至无法在 TextAreas 内滚动。
只有 DIV 按我预期的方式调整大小。
如何让 Vaadin 的 TextArea 在窗口调整大小时调整大小?