美文网首页
鸿蒙ArkTs如何实现Scroll容器组件中子组件吸顶效果

鸿蒙ArkTs如何实现Scroll容器组件中子组件吸顶效果

作者: alian_girl | 来源:发表于2024-06-05 21:58 被阅读0次

    ```

    @Entry

    @Component

    struct Index {

        @Builder

        CustomHeader() {

            Text('2222222')

                .height(30)

                .backgroundColor(Color.Gray)

                .width('100%')

        }

        build() {

            List({

                space: 10

            }) {

                ListItem() {

                    Text('111111')

                        .height(30)

                        .backgroundColor(Color.Gray)

                        .width('100%')

                }

                ListItemGroup({

                    header: this.CustomHeader,

                    space: 10

                }) {

                    ForEach(Array.from({

                        length: 20

                    }), (item: void, index: number) => {

                        ListItem() {

                            Text(index + '')

                                .height(30)

                                .backgroundColor('#f00')

                                .width('100%')

                        }

                    })

                }

            }

            .width('100%')

            .height(200)

            .sticky(StickyStyle.Header)

        }

    }

    export default Index

    ```

    华为开发者论坛

    相关文章

      网友评论

          本文标题:鸿蒙ArkTs如何实现Scroll容器组件中子组件吸顶效果

          本文链接:https://www.haomeiwen.com/subject/puxpqjtx.html