The object returned from document.getElementsByTagName('span')
is not compatible with an array object. You need to declare it as following:
let li: NodeListOf<HTMLElement> = document.getElementsByTagName('span');
If you really need this to be an array object you can use:
let li: NodeListOf<HTMLElement> = document.getElementsByTagName('span');
let liArray: Element[] = Array.prototype.slice.call(li);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…