当前位置:   article > 正文

ArkTS声明式开发范式:赋值显示,css样式,点击事件,页面跳转_arkts text 赋值

arkts text 赋值

ArkTS的基础:赋值显示,css样式,点击事件

一、页面效果

在这里插入图片描述

二、主要代码

页面地址:src/main/ets/pages/Second.ets

// Second.ets
import router from '@ohos.router';
@Entry
@Component
struct Second {
  @State message: string = 'Hi there'
  @State isShow: string = 'Hi this'

  build() {
    Row() {
      Column() {
        Text(this.isShow)

        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          
        Divider()

        Image('https://flag-digital.umss.cn/a9a36b88gy1hcuiaxan6dg20uk0h7x6w/a9a36b88gy1hcuiaxan6dg20uk0h7x6wjoanjqh3v.gif')
          .width(200)
          .height(200)

        Button() {
          Text('Back按钮')
            .fontSize(20)
            .fontWeight(FontWeight.Bold)
            .fontColor(Color.White)
        }
        .type(ButtonType.Capsule)
        .margin({
          top: 20
        })
        .backgroundColor('#409eff')
        .width('60%')
        .onClick(()=>{
          router.pushUrl({ url: 'pages/Index' }).then(() => {
            console.info('跳转到第二页了')
          }).catch((err)=>{
            console.error(`失败原因${err}`)
          })
        })
      }
      .width('100%')
    }
    .height('100%')
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号