import { _decorator, Component, EditBox, Label, Node } from 'cc'; import { Difficulty, UserDifficutyData } from '../../script/Manager/LocalDataMgr'; const { ccclass, property } = _decorator; @ccclass('DifficultyItem') export class DifficultyItem extends Component { @property(Label) labelInfo:Label = null; @property(EditBox) editBox:EditBox = null; @property(Label) labelScale:Label = null; _index:number = 0; init(index:number,scale:number) { this.labelInfo.string = `${index+1}号比例` this.editBox.string = `${scale}` this._index = index; this.labelScale.string = `${scale}`; } OnEditBoxChange(editBox:EditBox) { let scale = Number(editBox.string); if(isNaN(scale)) { return; } scale = Math.min(5,scale); Difficulty.difficutyData.scales[this._index] = scale; Difficulty.saveDifficutyData(); } refreshInput(text, editbox, customEventData) { // 这里的 text 表示修改完后的 EditBox 的文本内容 // 这里 editbox 是一个 EditBox 对象 // 这里的 customEventData 参数就等于你之前设置的 "foobar" this.labelScale.string = text; } }