mirror of
https://github.com/568071718/creator-collection-view
synced 2025-12-11 07:08:50 +00:00
添加一些演示场景
This commit is contained in:
33
list-3x/assets/common-cells/page-element.ts
Normal file
33
list-3x/assets/common-cells/page-element.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { _decorator, Component, Label, Node } from 'cc';
|
||||
import { YXCollectionView } from '../lib/yx-collection-view';
|
||||
import { YXTableLayout } from '../lib/yx-table-layout';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PageElement')
|
||||
export class PageElement extends Component {
|
||||
@property(Label)
|
||||
titleLabel: Label = null
|
||||
|
||||
@property(YXCollectionView)
|
||||
listComp: YXCollectionView = null
|
||||
|
||||
protected start(): void {
|
||||
this.listComp.numberOfItems = () => {
|
||||
return 10000
|
||||
}
|
||||
this.listComp.cellForItemAt = (indexPath, collectionView) => {
|
||||
const cell = collectionView.dequeueReusableCell(`cell`)
|
||||
cell.getChildByName('label').getComponent(Label).string = `${indexPath}`
|
||||
return cell
|
||||
}
|
||||
|
||||
let layout = new YXTableLayout()
|
||||
layout.spacing = 10
|
||||
layout.rowHeight = 100
|
||||
this.listComp.layout = layout
|
||||
|
||||
this.listComp.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user