当前的TextInput本身就是单行文本框。输入要多行输入框,请参考TextArea,https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textarea-V5\#maxlines10TextArea设置超过3行可以滚动显示,参考demo,textOverflow设置文本超长时的显示方式https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#textoverflowhttps://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#示例1@Entry @Component struct Index { @State message: string = 'Hello World'; controller: TextAreaController = new TextAreaController() build() { Column() { TextArea({ text:'测试一下', placeholder: 'The text area can hold an unlimited amount of text. input your word...', controller: this.controller }) .placeholderFont({ size: 16, weight: 400 }) .width(336) .constraintSize({ maxHeight: 75 }) .margin(20) .fontSize(16) .fontColor('#182431') // .maxLines(3) .focusable(true) // 组件是否获焦 .showCounter(false) }.height('30%') } }
当前的TextInput本身就是单行文本框。输入要多行输入框,请参考TextArea,https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textarea-V5\#maxlines10
TextArea设置超过3行可以滚动显示,参考demo,textOverflow设置文本超长时的显示方式
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#textoverflow
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#示例1