惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
博客园 - 司徒正美
博客园 - 【当耐特】
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
宝玉的分享
宝玉的分享
V
V2EX
S
SegmentFault 最新的问题
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
L
LangChain Blog
D
Docker
腾讯CDC

博客园 - 悄悄的来,匆匆的走

用npm 启动的前端项目在别人的电脑上访问不了,但是Java启动的项目可以 新建了一个微信群深圳技术交流群 OpenClaw 跨境电商 POD 领域实操指南 大文件清理工具 修改es的副本数-如果是测试环境的话 如果idea -java 编译内存不够修改这个地方 电脑往小米手机里快速传输文件方法 Flutter 开发文档 永久配置idea + Gradle 输出编码乱码(彻底解决) Firefox 插件开发教程地址 Ubuntu 安装Node Exporter Ubuntu 安装redis linux Ubuntu安装mysql 优化一个spring项目的启动耗时-日志1 在 Ubuntu 系统中使用apt卸载 Jenkins 清理atp安装的jenkins Ubuntu 安装 jenkins支持jdk1.8的版本 清理干净Jenkins apt 安装的 Jenkins CentOS安装maven
鸿蒙开发hello word
悄悄的来,匆匆的走 · 2025-12-03 · via 博客园 - 悄悄的来,匆匆的走

先做一个登录界面:

@Entry
@Component
struct login2 {
  // 定义输入框状态变量
  @State username: string = ''
  @State password: string = ''
  @State showPassword: boolean = false

  build() {
    Column() {
      // 应用图标
      Image($r('app.media.app_logo')) // 请在资源文件中添加对应图标
        .width(80)
        .height(80)
        .margin({ top: 80, bottom: 20 })

      // 标题
      Text('标题2364')
        .fontSize(24)
        .fontWeight(FontWeight.Bold)
        .margin({ bottom: 6 })

      // 副标题
      Text('login.subtitle')
        .fontSize(14)
        .fontColor('#666666')
        .margin({ bottom: 40 })

      // 用户名输入框
      TextInput({ placeholder: '请输入22' })
        .width('80%')
        .height(50)
        .borderRadius(25)
        .backgroundColor('#F5F5F5')
        .padding({ left: 20 })
        .margin({ bottom: 15 })
        .onChange(value => this.username = value)

      // 密码输入框
      TextInput({ placeholder: $r('app.string.password_hint') })
        .type(InputType.Password)
        .width('80%')
        .height(50)
        .borderRadius(25)
        .backgroundColor('#F5F5F5')
        .padding({ left: 20 })
        .margin({ bottom: 10 })
        .onChange(value => this.password = value)

      // 短信登录和忘记密码
      Row() {
        Text('sms.login')
          .fontSize(14)
          .fontColor('#1677FF')
          .margin({ left: '10%' })

        Text('忘记密码')
          .fontSize(14)
          .fontColor('#1677FF')
          .margin({ right: '10%' })
      }
      .width('100%')
      .justifyContent(FlexAlign.SpaceBetween)
      .margin({ bottom: 30 })

      // 登录按钮
      Button('登录')
        .width('80%')
        .height(50)
        .fontSize(16)
        .backgroundColor('#1677FF')
        .borderRadius(25)
        .margin({ bottom: 15 })
        .onClick(() => {
          // 登录逻辑处理
          this.handleLogin()
        })

      // 注册链接
      Text('注册')
        .fontSize(14)
        .fontColor('#1677FF')
        .onClick(() => {
          // 跳转到注册页面
        })
    }
    .width('100%')
    .height('100%')
    .backgroundColor('#FFFFFF')
  }

  // 登录处理方法
  private handleLogin() {
    // 实现登录逻辑
    if (!this.username) {
      // 提示用户名不能为空
      return
    }
    if (!this.password) {
      // 提示密码不能为空
      return
    }
    // 调用登录接口...
  }
}

posted on 2025-12-03 17:11  悄悄的来,匆匆的走  阅读(15)  评论()    收藏  举报