在Angular Material中,可以使用rows属性来设置TextArea的输入行数限制。下面是一个示例:
HTML模板:
在这个示例中,rows属性被设置为4,表示TextArea可以显示4行文本。
在组件的代码中,你需要定义一个变量来存储TextArea的值,这里我们使用textValue来存储输入的文本。
组件代码:
import { Component } from '@angular/core';
@Component({
selector: 'app-textarea-example',
templateUrl: './textarea-example.component.html',
styleUrls: ['./textarea-example.component.css']
})
export class TextareaExampleComponent {
textValue: string;
}
这样,就可以在Angular Material中的TextArea中设置输入行数的限制了。你可以根据需要调整rows属性的值来控制TextArea显示的行数。