(Arkts界面示例)ets pages Demo

Index.ets 文件

TypeScript 复制代码
import router from '@ohos.router'

@Entry//表示该自定义组件为入口组件
@Component //表示自定义组件
struct Index {//表示组件中的状态变量,状态变量变化会触发UI刷新
  @State changeValue: string = ''
  @State submitValue: string = ''
  controller: SearchController = new SearchController()

  build() {
    Column() {

      Search({ value: this.changeValue, placeholder: 'file name', controller: this.controller })
        .searchButton('SEARCH')
        .width(300)
        .height(50)
        .backgroundColor('#F5F5F5')
        .placeholderColor(Color.Grey)
        .placeholderFont({ size: 15, weight: 550 })
        .textFont({ size: 15, weight: 500 })
        .copyOption(CopyOptions.InApp)
        .onSubmit((value: string) => {
          this.submitValue = value
          router.pushUrl({url:'pages/'+this.submitValue})
        })
        .onChange((value: string) => {
          this.changeValue = value
        })
        .margin(20)

    }.width('100%')
  }
}

hello.ets

TypeScript 复制代码
import router from '@ohos.router'

@Entry
@Component
struct hello{
  build() {
    Column({ space: 5 }) {

      Text('首页').onClick(() => {
        router.pushUrl({ url: 'pages/Index' })
      })

      Text('Hello worid').fontSize(20)
    }.width('100%').margin({top:10})
  }
}
相关推荐
_muffinman29 分钟前
梁山派学习笔记1
笔记·学习
β添砖java12 小时前
2025最新快速构建企业级虚拟专用网络环境学习笔记
笔记·学习
qianpeng412 小时前
IDA PRO笔记
笔记
Yang_jie_0316 小时前
笔记:数据结构(顺序表)
数据结构·windows·笔记
Tom@敲代码18 小时前
js学习笔记-01
javascript·笔记·学习
巴巴媛66620 小时前
STM32学习笔记【32.BKP + RTC】
笔记·stm32·学习
能摆一天是一天20 小时前
Spring ai vectorstore 使用本地模型导致只能匹配可行度为1.0的内容的解决方法笔记
java·笔记·spring
进阶的DW21 小时前
Wiki + Graph + RAG 知识库建设笔记2
笔记
AOwhisky21 小时前
Linux(CentOS)系统管理入门笔记(第四期)——文件系统(下篇):文件与目录操作实战——cpmvmkdirrmln
linux·运维·笔记·centos·云计算·文件系统
bmy-happy21 小时前
网安专业课程笔记sale
笔记