@Entry
@Component
struct TextInputDemo {
controller: TextInputController = new TextInputController();
build() {
Column() {
TextInput({ controller: this.controller })
.onEditChange((isEditing: boolean) => {
if (isEditing) {
setTimeout(() => {
// The cursor will reset to the beginning of the text after 100ms
this.controller.caretPosition(0);
}, 100)
}
})
}
}
} 参考链接