这是界面的样子
export interface Patient {
doctors: [{
id: null,
gp: null,
}]
}
Run Code Online (Sandbox Code Playgroud)
这是我的元组
linkedDoctorShort: Array<any> = []; // will contain only the ID and GP
Run Code Online (Sandbox Code Playgroud)
我尝试了我在 StackOverflow 上找到的一些解决方案,但仍然出现相同的错误,尤其是当我想保存所有信息时:
onSave() {
const patientInfo: Patient = {
doctors: this.linkedDoctorShort,
};
Run Code Online (Sandbox Code Playgroud)
错误信息 :
类型“any[]”中缺少属性“0”,但类型“[{ id: string; gp:布尔值;}]'。
感谢您的帮助
嘿,我正在尝试创建一个计算器,通过在输入中键入一年并单击按钮,可以说明一年中有多少星期五,然后会出现一个警告()
<script>
function Fridaythe13(j) {
var count = document.getElementById('year').value;
var count = 0;
for (var month=0; month<12; month++) {
var d = new Date(j,month,13);
if(d.getDay() == 5){
count++;
}
}
return count;
}
document.getElementById("run").addEventListener("click", function(){
alert(Fridaythe13(count));
})
</script>
<input type="text" name="year" id="year" />
<section class="material">
<div class="actions">
<button type="button" id="run">Run</button>
</div>
</section> Run Code Online (Sandbox Code Playgroud)
当我点击按钮时,它说计数变量没有定义,但我用输入('年')声明它所以我不明白..感谢您提前为您的帮助!