0
这是我的代码
模板文件:
.ts 文件: loadAnswer(studentAnswer) { }
答案将显示在输入框中,但由于先前的答案又回来了,因此我无法在其上键入新答案。有什么解决办法吗? if (document.getElementById(question.id)) {
let inputs =
document.getElementById(question.id).getElementsByTagName('input') || [];
inputs.forEach((input, index) => {
input.value = studentAnswer[index]
})
}
答案 0 :(得分:0)
首先,让我们的代码更漂亮。
loadAnswer(studentAnswer){
if (document.getElementById(question.id)) {
let inputs = document.getElementById(question.id).getElementsByTagName('input') || [];
inputs.forEach((input, index) => {
input.value = studentAnswer[index]
})
}
}
您能与我们分享您的模板代码吗?功能看起来不错。