国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Harmony之學(xué)習(xí)Column&Row組件的使用

這篇具有很好參考價值的文章主要介紹了Harmony之學(xué)習(xí)Column&Row組件的使用。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1 概述

一個豐富的頁面需要很多組件組成,那么,我們?nèi)绾尾拍茏屵@些組件有條不紊地在頁面上布局呢?這就需要借助容器組件來實現(xiàn)。

容器組件是一種比較特殊的組件,它可以包含其他的組件,而且按照一定的規(guī)律布局,幫助開發(fā)者生成精美的頁面。容器組件除了放置基礎(chǔ)組件外,也可以放置容器組件,通過多層布局的嵌套,可以布局出更豐富的頁面。

ArkTS為我們提供了豐富的容器組件來布局頁面,本文將以構(gòu)建登錄頁面為例,介紹Column和Row組件的屬性與使用。
row組件使用,Harmony,學(xué)習(xí)

2 組件介紹

布局容器概念

線性布局容器表示按照垂直方向或者水平方向排列子組件的容器,ArkTS提供了Column和Row容器來實現(xiàn)線性布局。

  • Column表示沿垂直方向布局的容器。
  • Row表示沿水平方向布局的容器。

主軸和交叉軸概念

在布局容器中,默認(rèn)存在兩根軸,分別是主軸和交叉軸,這兩個軸始終是相互垂直的。不同的容器中主軸的方向不一樣的。

  1. 主軸:在Column容器中的子組件是按照從上到下的垂直方向布局的,其主軸的方向是垂直方向;在Row容器中的組件是按照從左到右的水平方向布局的,其主軸的方向是水平方向。
    row組件使用,Harmony,學(xué)習(xí)
  2. 交叉軸:與主軸垂直相交的軸線,如果主軸是垂直方向,則交叉軸就是水平方向;如果主軸是水平方向,則交叉軸是垂直方向。
    row組件使用,Harmony,學(xué)習(xí)

屬性介紹

了解布局容器的主軸和交叉軸,主要是為了讓大家更好地理解子組件在主軸和交叉軸的排列方式。

接下來,我們將詳細講解Column和Row容器的兩個屬性justifyContent和alignItems。
|

屬性名稱 描述
justifyContent 設(shè)置子組件在主軸方向上的對齊格式。
alignItems 設(shè)置子組件在交叉軸方向上的對齊格式。

1. 主軸方向的對齊(justifyContent)

子組件在主軸方向上的對齊使用justifyContent屬性來設(shè)置,其參數(shù)類型是FlexAlign。FlexAlign定義了以下幾種類型:

  • Start:元素在主軸方向首端對齊,第一個元素與行首對齊,同時后續(xù)的元素與前一個對齊。(默認(rèn))
    Column容器
@Entry
@Component
struct Index {
  @State message: string = 'Hello World'
  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.Start)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.Start)
      .width('100%')
      // .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • Center:元素在主軸方向中心對齊,第一個元素與行首的距離以及最后一個元素與行尾距離相同。
    Column容器
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.Center)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.Center)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • End:元素在主軸方向尾部對齊,最后一個元素與行尾對齊,其他元素與后一個對齊。
    Column容器
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.End)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.End)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • SpaceBetween:元素在主軸方向均勻分配彈性元素,相鄰元素之間距離相同。 第一個元素與行首對齊,最后一個元素與行尾對齊。
    Column容器
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceBetween)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceBetween)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • SpaceAround:元素在主軸方向均勻分配彈性元素,相鄰元素之間距離相同。 第一個元素到行首的距離和最后一個元素到行尾的距離是相鄰元素之間距離的一半。
    Column
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceAround)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceAround)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • SpaceEvenly:元素在主軸方向等間距布局,無論是相鄰元素還是邊界元素到容器的間距都一樣。
    Column容器
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceEvenly)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
Row容器

@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .justifyContent(FlexAlign.SpaceEvenly)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

2.交叉軸方向的對齊(alignItems)

子組件在交叉軸方向上的對齊方式使用alignItems屬性來設(shè)置。

Column容器的主軸是垂直方向,交叉軸是水平方向,其參數(shù)類型為HorizontalAlign(水平對齊),HorizontalAlign定義了以下幾種類型:

  • Start:設(shè)置子組件在水平方向上按照起始端對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(HorizontalAlign.Start)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • Center(默認(rèn)值):設(shè)置子組件在水平方向上居中對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(HorizontalAlign.Center)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • End:設(shè)置子組件在水平方向上按照末端對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(HorizontalAlign.End)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
Row容器的主軸是水平方向,交叉軸是垂直方向,其參數(shù)類型為VerticalAlign(垂直對齊),VerticalAlign定義了以下幾種類型:

  • Top:設(shè)置子組件在垂直方向上居頂部對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(VerticalAlign.Top)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • Center(默認(rèn)值):設(shè)置子組件在豎直方向上居中對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(VerticalAlign.Center)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)

  • Bottom:設(shè)置子組件在豎直方向上居底部對齊。
@Entry
@Component
struct Index {
  @State message: string = 'Hi'

  build() {
      Row() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .alignItems(VerticalAlign.Bottom)
      .width('100%')
      .height('100%')
  }
}

row組件使用,Harmony,學(xué)習(xí)
接口介紹
接下來,我們介紹Column和Row容器的接口。

容器組件 接口
Column Column(value?:{space?: string number})
Row Row(value?:{space?: string number})

Column和Row容器的接口都有一個可選參數(shù)space,表示子組件在主軸方向上的間距。

效果如下:
row組件使用,Harmony,學(xué)習(xí)

3 參考鏈接

Column組件的相關(guān)API參考:Column組件。
Row組件的相關(guān)API參考:Row組件。文章來源地址http://www.zghlxwxcb.cn/news/detail-789277.html

到了這里,關(guān)于Harmony之學(xué)習(xí)Column&Row組件的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Element UI組件中el-col、el-row布局學(xué)習(xí)筆記

    Element UI組件中el-col、el-row布局學(xué)習(xí)筆記

    el-col:列。是Element UI布局中的核心組件,他的作用的將一行分成24個網(wǎng)格,為了方便我們在不同的設(shè)備上適配不同的屏幕大小。我們可以通過指定span屬性來確定一行中所占的網(wǎng)格數(shù)。 el-row:行。包裹在el-col外層,其中可以有無數(shù)個el-col。 ? 在正常形態(tài)下,:span默認(rèn)為24。假如

    2024年02月15日
    瀏覽(21)
  • element中表格組件的row-class-name和class-name屬性的使用以及無效處理

    element中表格組件的row-class-name和class-name屬性的使用以及無效處理

    1.這兩個屬性的使用,row-class-name用在el-table標(biāo)簽上,class-name用在el-table-column標(biāo)簽上。兩個屬性即可綁定類名也可綁定函數(shù) 2.綁定函數(shù)時就可以通過條件來決定哪行需要添加樣式 3.樣式無效處理 樣式?jīng)]有效果的原因在于添加的樣式不是全局樣式,所以只需要將scoped去除或者自

    2024年01月20日
    瀏覽(28)
  • 解決Data too long for column ‘xxx‘ at row 1問題以及深入理解mysql的字符串?dāng)?shù)據(jù)類型(char,varchar,enum,text,longtext...)

    今天在測試環(huán)境新增數(shù)據(jù)時,報出如是錯誤: Data too long for column \\\'apply_service_type\\\' at row 1 。 為了復(fù)現(xiàn)這個問題,我特地在本地數(shù)據(jù)庫中增加如下 test 表:

    2023年04月17日
    瀏覽(26)
  • SQL執(zhí)行報錯Incorrect string value: ‘\xF0\x9F\x98\x81\xF0\x9F...‘ for column ‘XXX‘ at row 1...

    SQL執(zhí)行報錯Incorrect string value: ‘\xF0\x9F\x98\x81\xF0\x9F...‘ for column ‘XXX‘ at row 1...

    分享一個數(shù)據(jù)庫執(zhí)行插入和修改語句可能會出現(xiàn)的bug Incorrect string value: ‘xF0x9Fx98x81xF0x9F…’ for column ‘name’ at row 1… 再來看下實際項目中服務(wù)器報錯打印的日志 數(shù)據(jù)庫某字段設(shè)置的是 utf8字符集 ,在執(zhí)行插入或修改語句時該字段傳入的值是 非utf8格式(表情或特殊字符

    2024年02月07日
    瀏覽(29)
  • Vue(element ui)中行操作row參數(shù)的使用

    Vue(element ui)中行操作row參數(shù)的使用

    ????????在使用element ui或Vue中當(dāng)我們要對表格中的數(shù)據(jù)按行進行特殊操作或標(biāo)記時,通常通過在vue中methods方法中操作row參數(shù)來訪問該行的索引或是單元格中的數(shù)據(jù)進行對應(yīng)操作。 樣式表格中 Vue中 ?通過row.rowIndex===?可以訪問當(dāng)前行的索引,就可以通過指定 Table 組件的ro

    2024年02月12日
    瀏覽(19)
  • row_number 和 cte 使用實例:按照隊列進行數(shù)據(jù)抵消

    row_number 和 cte 使用實例:按照隊列進行數(shù)據(jù)抵消

    今天無聊的翻了翻以前的論壇的帖子。。。嗯,想把一些沒有什么價值的消息記錄給刪除掉,就是那些專家分獲取記錄。 畢竟,現(xiàn)在論壇已經(jīng)改名叫社區(qū)了,也取消了專家分這個設(shè)置了。 在進行記錄刪除前,老顧覺得,有些比較有意思的問題,還是把記錄保留下來,比在所

    2024年02月16日
    瀏覽(25)
  • PostMan使用之POST請求Body中row的JSON數(shù)據(jù)內(nèi)容設(shè)置換行

    PostMan使用之POST請求Body中row的JSON數(shù)據(jù)內(nèi)容設(shè)置換行

    在使用postman或者APIfox的時候發(fā)現(xiàn)無法實現(xiàn)換行,這個時候我去網(wǎng)上查閱了很多資料找到了,分享給兄弟們 1、請你別悄悄松開你的夢想,遲早有—天它會在你手里發(fā)光。 2、曾經(jīng)擁有的,不要放棄;已經(jīng)得到的,更要珍惜;屬于別人的,不可貪取;想要得到的,必須努力。但最重

    2024年01月24日
    瀏覽(44)
  • MySQL報錯:ERROR 1118 (42000): Row size too large. 或者 Row size too large (> 8126).

    MySQL報錯:ERROR 1118 (42000): Row size too large. 或者 Row size too large (> 8126).

    今天拿到一個建語句時,大概二百多個字段,然后大部分類型是 string 的,要求建 MySQL 的表。首先將 string 替換為 varchar(xx),然后執(zhí)行了一下語句,報錯如下所示: ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhe

    2023年04月09日
    瀏覽(21)
  • 無涯教程-JavaScript - ROW函數(shù)

    ROW函數(shù)返回引用的行號。 Argument 描述 Required/Optional Reference 您想要其行號的單元格或單元格范圍。 如果省略引用,則假定它是出現(xiàn)ROW函數(shù)的單元格的引用。 請參閱下面的注釋。 Optional 如果引用是一個單元格范圍,并且如果將ROW作為垂直數(shù)組輸入,則ROW將引用的行號作為垂直數(shù)組

    2024年02月07日
    瀏覽(30)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包