mirror of
https://github.com/568071718/creator-collection-view
synced 2025-12-08 21:58:51 +00:00
30 lines
911 B
TypeScript
30 lines
911 B
TypeScript
import { _decorator, Component, Label, math, Node, Sprite } from 'cc';
|
|
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 {
|
|
protected start(): void {
|
|
const listComp = this.node.getChildByName('list').getComponent(YXCollectionView)
|
|
|
|
listComp.numberOfItems = () => {
|
|
return 10000
|
|
}
|
|
listComp.cellForItemAt = (indexPath, collectionView) => {
|
|
const cell = collectionView.dequeueReusableCell(`cell`)
|
|
cell.getChildByName('label').getComponent(Label).string = `${indexPath}`
|
|
return cell
|
|
}
|
|
|
|
let layout = new YXTableLayout()
|
|
layout.spacing = 20
|
|
layout.rowHeight = 100
|
|
listComp.layout = layout
|
|
|
|
listComp.reloadData()
|
|
}
|
|
}
|
|
|