
class Article {public id: numberpublic title: stringpublic content: stringconstructor(id: number, title: string, content: string) {this.id = idthis.title = titlethis.content = content}
}
@Component
struct ArticleComponent {@Prop article: Articlebuild() {Row() {Column() {Image($r('app.media.startIcon')).width(80).height(80).margin({ right: 15 }) }Column() {Text(this.article.title).fontSize(20).margin({ bottom: 5 })Text(this.article.content).fontSize(16).fontColor('#666666')}.alignItems(HorizontalAlign.Start) .width('100%').height('100%')}.padding(18).borderRadius(16).backgroundColor('#EEEEEE').width('100%').height(120).justifyContent(FlexAlign.SpaceBetween)}
}
@Entry
@Component
struct UITest10 {@State isListReachEnd: boolean = false @State article_array: Array<Article> = [new Article(1, '第1篇文章', '文章的内容和介绍'),new Article(2, '第2篇文章', '文章的内容和介绍'),new Article(3, '第3篇文章', '文章的内容和介绍'),new Article(4, '第4篇文章', '文章的内容和介绍'),new Article(5, '第5篇文章', '文章的内容和介绍'),new Article(6, '第6篇文章', '文章的内容和介绍')]build() {Column() {List() {ForEach(this.article_array, (item: Article) => {ArticleComponent({ article: item }).margin({ top: 15 })})}.onReachEnd(() => {this.isListReachEnd = true}).parallelGesture(PanGesture({ direction: PanDirection.Up, distance: 80 }).onActionStart(() => {if (this.isListReachEnd) { let count = this.article_array.lengthlet new_id = count += 1this.article_array.push(new Article(new_id, `第${new_id}篇文章`, '文章的内容和介绍'))this.isListReachEnd = false}})).padding(10).scrollBar(BarState.Off) }.width('100%').height('100%')}
}