中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
import router from '@ohos.router'; @Entry @Component struct LoginPage { @State ReserveAccount: string = ''; @State ReservePassword: string = ''; private length: number = 0; onBackPress() { router.back(); return true; } build() { Column() { Text("用户登录") .fontSize(24) .fontColor('#000000') .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Start) .width('100%') .margin({ top: 18 }) TextInput({ placeholder: '账号' }) .opacity(0.6) .type(InputType.USER_NAME) .placeholderColor(0x182431) .width('100%') .placeholderFont({ size: 16, weight: FontWeight.Regular }) .margin({ top: 32, bottom: 8 }) .onChange((value: string) => { this.ReserveAccount = value; this.length = value.length; }) .caretPosition(this.length) TextInput({ placeholder: '密码' }) .type(InputType.Password) .placeholderColor(0x182431) .width('100%') .opacity(0.6) .showPasswordIcon(true) .placeholderFont({ size: 16, weight: FontWeight.Regular }) .onChange((value: string) => { this.ReservePassword = value; }) .margin({ bottom: 36 }) Button('提交', { type: ButtonType.Capsule, stateEffect: false }) .borderRadius(20) .width('100%') .height(40) .enabled((this.ReserveAccount !== '') && (this.ReservePassword !== '')) .onClick(() => { router.pushUrl({ url: 'pages/Login', params: { src: '账户登录' } }, (err) => { if (err) { console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); return; } console.info('Invoke pushUrl succeeded.'); }) }) } .padding({ left: 24, right: 24 }) .height('100%') .width('100%') } }