我正在处理一个表单,在其中输入必要的详细信息后点击保存按钮,我收到以下错误:
Uncaught TypeError: e.reportValidity[s] is not a function
at HTMLButtonElement.<anonymous>
at f (Line#57)
at HTMLDivElement.f.handle
at HTMLDivElement.dispatch
const legalityMethod = function () {
return 'reportValidity' in document.createElement('input') ? 'reportValidity' : 'checkValidity';
}();
第 57 行对应于下面的 while 循环;
function validate(form, field) {
while (m && m--) {
switch (fields[m]) {
case 'hello_world':
form.hello_world.setCustomValidity(config.language['amazing_world']);
break;
}
}
return form.reportValidity[legalityMethod](); //line#57
}
问题陈述:
我想知道这个错误背后的原因是什么以及如何摆脱这个错误。