是否在typescript的类型元素中不存在选中的属性?
toggle(source) {
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] != source)
checkboxes[i].checked= source.checked;
}
发布于 2020-04-05 09:40:49
这是因为只有HTMLInputElement
在typescript中有checked
属性。因此,您只需使用type-argument:
var checkboxes = document.querySelectorAll<HTMLInputElement>('input[type="checkbox"]');
https://stackoverflow.com/questions/61040546
复制