Files
creator-collection-view/list-3x/assets/home/home.ts

30 lines
911 B
TypeScript
Raw Normal View History

2025-01-08 23:03:52 +08:00
import { _decorator, Component, Label, math, Node, Sprite } from 'cc';
2024-12-14 15:32:38 +08:00
import { YXCollectionView } from '../lib/yx-collection-view';
import { YXTableLayout } from '../lib/yx-table-layout';
const { ccclass, property } = _decorator;
@ccclass('home')
export class home extends Component {
2025-01-08 23:03:52 +08:00
protected start(): void {
2025-12-07 20:00:23 +08:00
const listComp = this.node.getChildByName('list').getComponent(YXCollectionView)
2025-01-08 23:03:52 +08:00
2025-12-07 20:00:23 +08:00
listComp.numberOfItems = () => {
return 10000
2025-01-08 23:03:52 +08:00
}
listComp.cellForItemAt = (indexPath, collectionView) => {
const cell = collectionView.dequeueReusableCell(`cell`)
cell.getChildByName('label').getComponent(Label).string = `${indexPath}`
return cell
2024-12-14 15:32:38 +08:00
}
2025-01-08 23:03:52 +08:00
let layout = new YXTableLayout()
layout.spacing = 20
layout.rowHeight = 100
listComp.layout = layout
listComp.reloadData()
2024-12-14 15:32:38 +08:00
}
}