import { _decorator , Component , Node , RichText , UITransform , Size , Label } from 'cc' ; const { ccclass , property } = _decorator ; @ ccclass ( 'LifeTrackItem' ) export class LifeTrackItem extends Component { @ property ( { type : Label } ) public agaLabel : Label ; @ property ( { type : RichText } ) public descriptionText : RichText ; @ property ( { type : Node } ) public descriptionBG : Node ; @ property ( { type : Node } ) public lineNode : Node ; start ( ) { } public setData ( age , description ) { this . agaLabel . string = age ; this . descriptionText . string = description ; const height = this . getHeight ( ) ; const descriptionBGTrans = this . descriptionBG . getComponent ( UITransform ) ; const size = descriptionBGTrans . contentSize ; descriptionBGTrans . contentSize = new Size ( size . width , height ) ; } public getHeight ( ) { const size = this . descriptionText . getComponent ( UITransform ) . contentSize ; return size . height ; } public setLineLength ( length ) { const lineNodeTrans = this . lineNode . getComponent ( UITransform ) ; const size = lineNodeTrans . contentSize ; lineNodeTrans . contentSize = new Size ( size . width , length ) ; } }