export class Medidor {
onUpdateFeature() {
}
id: number;
gas: any;
name: string;
qualification: number;
maxQualification: number;
}
export default function CircleMeter(props: Medidor) {
const renderMeter = () => {
let circles = [] as JSX.Element[];
for (let circle = 1; circle <= props.maxQualification; ++circle) {
circles.push(<FiCircle
className={circle <= props.qualification ? 'filled-circle' : 'circle'}
onClick={() => onCircleClicked(circle)} />);
}
circles.push(<input value={props.qualification}></input>)
return circles;
}
const onCircleClicked = (qualification: number) => {
const gas = props.gas.copy();
gas.qualification = qualification;
props.onUpdateFeature();
}
return <div key={props.gas.id}>
{props.gas.name}
<div>{renderMeter()}</div>
</div>
}
我在这里有点迷失了,我得到了无法读取的未定义错误的属性'id',但我的vscode中有0个错误。有人可以帮助我更好地理解这一点吗?我需要声明什么才能让我的函数识别ID?