0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學(xué)習在線(xiàn)課程
  • 觀(guān)看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區
會(huì )員中心
創(chuàng )作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內不再提示

HarmonyOS應用開(kāi)發(fā)教程 圓角list實(shí)現

鴻蒙時(shí)代 ? 來(lái)源:鴻蒙時(shí)代 ? 作者:鴻蒙時(shí)代 ? 2022-04-10 10:35 ? 次閱讀

效果展示:

poYBAGJQ8AGAevJkAAE9uBjWCSE941.png

Hml


{{ $item.indexTxt }}
{{ $item.title }}{{ $item.desc }}
list_arrow_gray.png
{{ $item.indexTxt }}
{{ $item.title }}{{ $item.desc }}
list_arrow_gray.png
{{ $item.indexTxt }}
{{ $item.title }}{{ $item.desc }}
list_arrow_gray.png

Css

.container {
    flex-direction: column;
    align-items: center;
    background-color: #5e7c85;
    padding-top: 52px;
}

.topList_corner_round_bg {
    width: 100%;
    height: 240px;
    border: 1px solid #000000;
    text-align: center;
    margin-left: 10px;
    margin-right: 10px;
    border-radius: 8px;
    divider-color: #000000;
    divider-height: 1px;
}

.middleList_corner_round_bg {
    width: 100%;
    height: 160px;
    border: 1px solid #000000;
    text-align: center;
    margin-top: 10px;
    margin-left: 10px;
    margin-right: 10px;
    border-radius: 8px;
    divider-color: #000000;
    divider-height: 1px;
}

.bottomList_corner_round_bg {
    width: 100%;
    height: 80px;
    border: 1px solid #000000;
    text-align: center;
    margin-top: 10px;
    margin-left: 10px;
    margin-right: 10px;
    border-radius: 8px;
    divider-color: #000000;
    divider-height: 1px;
}

/**
選中背景
*/

.list_corner_round_top {
    width: 100%;
    height: 80px;
    border: 1px solid #000000;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    background: linear-gradient(270deg, #BFEEFF, #40B9FF);
}

.list_corner_round_mid {
    width: 100%;
    height: 80px;
    border: 1px solid #000000;
    background: linear-gradient(270deg, #BFEEFF, #40B9FF);
}

.list_corner_round_bottom {
    width: 100%;
    height: 78px;
    border: 1px solid #000000;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
    background: linear-gradient(270deg, #BFEEFF, #40B9FF);
}

.list_corner_round {
    width: 100%;
    height: 78px;
    border: 1px solid #000000;
    border-radius: 7px;
    background: linear-gradient(270deg, #BFEEFF, #40B9FF);
}

.todo_item_top {
    width: 100%;
    height: 80px;
    border: 1px solid #000000;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    background: linear-gradient(0deg, #FFFFFF, #FFFFFF);
}

.todo_item_mid {
    width: 100%;
    height: 80px;
    border: 1px solid #000000;
    background: linear-gradient(0deg, #FFFFFF, #FFFFFF);
}

.todo_item_bottom {
    width: 100%;
    height: 78px;
    border: 1px solid #000000;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
    background: linear-gradient(0deg, #FFFFFF, #FFFFFF);
}

.todo_item_round {
    width: 100%;
    height: 78px;
    border: 1px solid #000000;
    border-radius: 7px;
    background: linear-gradient(0deg, #FFFFFF, #FFFFFF);
}

.item_title {
    font-size: 22px;
    text-align: left;
    margin-start: 10px;
    font-weight: 600;
}

.item_desc {
    font-size: 16px;
    margin-top: 10px;
    color: #77787b;
    font-weight: 400;
}

.div_icon {
    width: 50px;
    height: 100%;
    align-items: center;
    justify-content: center;
    margin-start: 10px;
}

.item_icon {
    height: 50px;
    width: 100%;
    align-items: center;
    border-radius: 35px;
    background-color: orange;
}

.txt_title {
    font-size: 22px;
    font-weight: 600;
}

.div_right {
    flex-direction: column;
    justify-content: center;
}

.div_arrow {
    height: 100%;
    width: 100%;
    margin-end: 10px;
    justify-content: center;
    align-items: center;
}

.item_arrow {
    margin-start: 316;
    height: 14px;
    width: 14px;
}

Js

import prompt from '@system.prompt';

var timeoutID;

const DURATION = 600;

export default {
    data: {
        topList: [{
                      title: 'title3_1',
                      desc: 'description3_1',
                      cls: 'todo_item_top',
                      iconColor: '#99FF0000',
                      txtColor: 'white',
                      indexTxt: 'R'
                  }, {
                      title: 'title3_2',
                      desc: 'description3_2',
                      cls: 'todo_item_mid',
                      iconColor: '#99FF7D00',
                      txtColor: 'white',
                      indexTxt: 'T'
                  }, {
                      title: 'title3_3',
                      desc: 'description3_3',
                      cls: 'todo_item_bottom',
                      iconColor: '#99FF00FF',
                      txtColor: 'white',
                      indexTxt: 'Y'
                  }
        ],
        middleList: [{
                         title: 'title2_1',
                         desc: 'description2_1',
                         cls: 'todo_item_top',
                         iconColor: '#9900FF00',
                         txtColor: 'white',
                         indexTxt: 'U'
                     }, {
                         title: 'title2_2',
                         desc: 'description2_2',
                         cls: 'todo_item_bottom',
                         iconColor: '#9900FFFF',
                         txtColor: 'white',
                         indexTxt: 'I'
                     }
        ],
        bottomList: [{
                         title: 'title1_1',
                         desc: 'description1_1',
                         cls: 'todo_item_round',
                         iconColor: '#990000FF',
                         txtColor: 'white',
                         indexTxt: 'O'
                     }
        ]
    },
    onTopListItemClick($idx) {
        console.info("id = " + $idx);
        let index = $idx;
        let size = this.topList.length;
        if (index == -1) {
            for (let i = 0; i < size; i++) {
                if (i == 0) {
                    this.topList[i].cls = "todo_item_top"
                } else if (i == size - 1) {
                    this.topList[i].cls = "todo_item_bottom"
                } else {
                    this.topList[i].cls = "todo_item_mid"
                }
            }
            return;
        }
        this.onMiddleListItemClick(-1);
        this.onBottomListItemClick(-1);
        prompt.showToast({
            message: this.topList[index].title
        });
        for (let i = 0; i < size; i++) {
            if (index == i) {
                if (i == 0) {
                    this.topList[i].cls = "list_corner_round_top"
                } else if (i == size - 1) {
                    this.topList[i].cls = "list_corner_round_bottom"
                } else {
                    this.topList[i].cls = "list_corner_round_mid"
                }

                clearTimeout(timeoutID);
                timeoutID = setTimeout(this.clearTopItemBg, DURATION);
            } else {
                if (i == 0) {
                    this.topList[i].cls = "todo_item_top"
                } else if (i == size - 1) {
                    this.topList[i].cls = "todo_item_bottom"
                } else {
                    this.topList[i].cls = "todo_item_mid"
                }
            }
        }
    },
    onMiddleListItemClick($idx) {
        console.info("id = " + $idx);
        let index = $idx;
        if (index == -1) {
            for (let i = 0; i < 2; i++) {
                if (i == 0) {
                    this.middleList[i].cls = "todo_item_top"
                } else {
                    this.middleList[i].cls = "todo_item_bottom"
                }
            }
            return;
        }
        this.onTopListItemClick(-1);
        this.onBottomListItemClick(-1)
        prompt.showToast({
            message: this.middleList[index].title
        });
        for (let i = 0; i < 2; i++) {
            if (index == i) {
                if (i == 0) {
                    this.middleList[i].cls = "list_corner_round_top"
                } else {
                    this.middleList[i].cls = "list_corner_round_bottom"
                }

                clearTimeout(timeoutID);
                timeoutID = setTimeout(this.clearMiddleItemBg, DURATION);
            } else {
                if (i == 0) {
                    this.middleList[i].cls = "todo_item_top"
                } else {
                    this.middleList[i].cls = "todo_item_bottom"
                }
            }
        }
    },
    onBottomListItemClick($idx) {
        console.info("id = " + $idx);
        let index = $idx;
        if (index == -1) {
            this.bottomList[0].cls = "todo_item_round"
            return;
        }
        this.onTopListItemClick(-1);
        this.onMiddleListItemClick(-1);
        prompt.showToast({
            message: this.bottomList[index].title
        });
        for (let i = 0; i < 2; i++) {
            this.bottomList[0].cls = "list_corner_round"
            clearTimeout(timeoutID);
            timeoutID = setTimeout(this.clearBottomItemBg, DURATION);
        }
    },
    clearTopItemBg() {
        this.onTopListItemClick(-1);
    },
    clearMiddleItemBg() {
        this.onMiddleListItemClick(-1);
    },
    clearBottomItemBg() {
        this.onBottomListItemClick(-1);
    }
}
聲明:本文內容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權轉載。文章觀(guān)點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習之用,如有內容侵權或者其他違規問(wèn)題,請聯(lián)系本站處理。 舉報投訴
  • 鴻蒙系統
    +關(guān)注

    關(guān)注

    183

    文章

    2626

    瀏覽量

    65462
  • HarmonyOS
    +關(guān)注

    關(guān)注

    79

    文章

    1914

    瀏覽量

    29498
收藏 人收藏

    評論

    相關(guān)推薦

    HarmonyOS開(kāi)發(fā)案例:【使用List組件實(shí)現設置項】

    使用List組件、Toggle組件以及Router接口,實(shí)現一個(gè)簡(jiǎn)單的設置頁(yè),點(diǎn)擊將跳轉到對應的詳細設置頁(yè)面。
    的頭像 發(fā)表于 05-10 17:01 ?406次閱讀
    <b class='flag-5'>HarmonyOS</b><b class='flag-5'>開(kāi)發(fā)</b>案例:【使用<b class='flag-5'>List</b>組件<b class='flag-5'>實(shí)現</b>設置項】

    HarmonyOS智能硬件怎么實(shí)現總線(xiàn)驅動(dòng)開(kāi)發(fā)?

    想要問(wèn)問(wèn),HarmonyOS智能硬件是怎么實(shí)現總線(xiàn)驅動(dòng)開(kāi)發(fā)的?
    發(fā)表于 09-18 10:37

    HarmonyOS應用開(kāi)發(fā)-UI設計開(kāi)發(fā)與預覽

    `. 介紹通過(guò)智能表待辦應用開(kāi)發(fā),讓開(kāi)發(fā)者了解智能表HarmonyOS應用開(kāi)發(fā)的全流程,實(shí)現從工程創(chuàng )建到界面預覽全過(guò)程。使用HUAWEIDe
    發(fā)表于 09-23 17:51

    HarmonyOS】圖片圓角功能

    前輩的神器),只能靠自己手x代碼,廢話(huà)不多說(shuō),來(lái)看下鴻蒙系統里如何實(shí)現基本的圖片圓角功能吧。如今大部分美術(shù)在設計樣式的時(shí)候,都會(huì )給圖片帶上圓角,在鴻蒙開(kāi)發(fā)過(guò)程中,一定會(huì )遇到要對圖片進(jìn)行
    發(fā)表于 10-19 13:12

    鴻蒙系統應用開(kāi)發(fā)之JS實(shí)現一個(gè)簡(jiǎn)單的List

    原文鏈接:https://harmonyos.51cto.com/posts/1715在之前的文章鴻蒙應用開(kāi)發(fā)之怎么更好的遠程連接手表模擬器做調試里我運行了一個(gè)穿戴設備的應用,利用JS UI實(shí)現了一
    發(fā)表于 11-13 10:32

    #HarmonyOS征文#HarmonyOSAPP開(kāi)發(fā)category list模板體驗分享

    一、樣式與功能項目名稱(chēng): jltf_template項目語(yǔ)言: JAVAmodule:category list體驗模板:category list工具:deveco studio效果如下二、主要
    發(fā)表于 07-04 10:21

    HarmonyOS 應用開(kāi)發(fā)在線(xiàn)體驗-to do list

    一、技術(shù)相關(guān) 使用語(yǔ)言:Js體驗內容: to do list工具:在線(xiàn)開(kāi)發(fā)https://playground.harmonyos.com/#/cn/onlineDemo?ha_source
    發(fā)表于 08-14 15:48

    HarmonyOSAPP開(kāi)發(fā) --list-item-group練習

    開(kāi)發(fā)過(guò)程部分代碼如下圖Hml CSS JS 相關(guān)問(wèn)題討論 1,For=”listgroup’ in list的作用,id里是不是list所存放的數值給了listgroup?還是list
    發(fā)表于 08-19 11:26

    HarmonyOS應用開(kāi)發(fā)-圓角list實(shí)現

    效果展示:Hml<div class="container"> <list class="
    發(fā)表于 04-09 11:00

    CAD制圖中倒圓角的技巧

    圓角命令是FILLET,圓角功能可使用與對象相切且指定半徑的圓弧來(lái)連接兩個(gè)對象??梢詣?chuàng )建兩種圓角,內角點(diǎn)稱(chēng)為內圓角,外角點(diǎn)稱(chēng)為外圓角??梢?/div>
    發(fā)表于 10-19 15:03 ?1.8w次閱讀
    CAD制圖中倒<b class='flag-5'>圓角</b>的技巧

    HarmonyOS開(kāi)發(fā)者日 鴻蒙是否會(huì )有新進(jìn)展

    據悉華為 HarmonyOS 應用開(kāi)發(fā)在線(xiàn)體驗網(wǎng)站現已上線(xiàn),開(kāi)發(fā)者可以通過(guò)在線(xiàn)體驗“To-Do List”Demo,但是需要注意的是“To-Do L
    的頭像 發(fā)表于 04-25 09:58 ?1737次閱讀

    華為開(kāi)發(fā)HarmonyOS零基礎入門(mén):四步實(shí)現HarmonyOS應用

    華為開(kāi)發(fā)HarmonyOS零基礎入門(mén):四步實(shí)現HarmonyOS應用,可以自定義主鍵實(shí)際應用在開(kāi)發(fā)者界面。
    的頭像 發(fā)表于 10-23 10:05 ?1773次閱讀
    華為<b class='flag-5'>開(kāi)發(fā)</b>者<b class='flag-5'>HarmonyOS</b>零基礎入門(mén):四步<b class='flag-5'>實(shí)現</b><b class='flag-5'>HarmonyOS</b>應用

    華為開(kāi)發(fā)HarmonyOS零基礎入門(mén):Word圖片資源支持預覽效果

    華為開(kāi)發(fā)HarmonyOS零基礎入門(mén):Word圖片資源支持預覽效果,list主鍵函數可以做布局,呈現多個(gè)堆疊顯示效果。
    的頭像 發(fā)表于 10-23 10:12 ?1259次閱讀
    華為<b class='flag-5'>開(kāi)發(fā)</b>者<b class='flag-5'>HarmonyOS</b>零基礎入門(mén):Word圖片資源支持預覽效果

    實(shí)現PCB板邊倒圓角

    看下圖: PCB外形倒圓角的點(diǎn),剛好就是我們凸包需求出的點(diǎn),接下來(lái)我們將玩轉凸包了,只要求出凸包,那么就可以實(shí)現PCB板邊倒圓角啦。
    的頭像 發(fā)表于 05-07 14:28 ?1w次閱讀

    HarmonyOS開(kāi)發(fā):舒爾特方格游戲

    為豐富 HarmonyOS 對云端開(kāi)發(fā)的支持、實(shí)現 HarmonyOS 生態(tài)端云聯(lián)動(dòng),DevEco Studio 推出了云開(kāi)發(fā)功能,
    的頭像 發(fā)表于 06-19 15:05 ?556次閱讀
    <b class='flag-5'>HarmonyOS</b>云<b class='flag-5'>開(kāi)發(fā)</b>:舒爾特方格游戲
    亚洲欧美日韩精品久久_久久精品AⅤ无码中文_日本中文字幕有码在线播放_亚洲视频高清不卡在线观看