文本框内容变化,标题也变化
1@Entry 2@Component 3struct Index { 4 @State message: string = 'Hello World' 5 checkMe = () => { 6 this.message = 'Harmony' 7 } 8 inputEvent = (event: ClickEvent) => { 9 10 } 11 12 build() { 13 Column({ 14 space: 5 15 }) { 16 Text(this.message) 17 Button('点击').onClick(this.checkMe) 18 TextInput({ 19 placeholder: '请输入内容', 20 text: $$this.message 21 }).onBlur(() => { 22 console.log('123') 23 }) 24 TextInput() 25 Divider() 26 } 27 .width('100%') 28 .height('100%') 29 } 30}
1@Entry 2@Component 3struct Index { 4 @State message: string = 'Hello World' 5 6 checkMe() { 7 this.message = 'xxx' 8 } 9 10 build() { 11 Column({ 12 space: 5 13 }) { 14 Text(this.message) 15 Button('点击').onClick(this.checkMe.bind(this)) 16 } 17 .width('100%') 18 .height('100%') 19 } 20}
Copyright ©2010-2022 比特日记 All Rights Reserved.
Powered By 可尔物语