TS 报错:
此表达式不可调用。
Snake.ts(67, 63): 是否缺少分号?
类型 "String" 没有调用签名。ts(2349)
let XX = (this.bodies[i-1] as HTMLElement).offsetLeft let YY = (this.bodies[i-1] as HTMLElement).offsetTop // 将值设置为当前身体上 (this.bodies[i] as HTMLElement).style.left = XX + 'px' (this.bodies[i] as HTMLElement).style.top = YY + 'px'
解决方案:
标签:style,TypeScript,ts,YY,调用,HTMLElement,bodies From: https://www.cnblogs.com/sssong123/p/16814160.html在每一个后面加上 ;
let XX = (this.bodies[i-1] as HTMLElement).offsetLeft; let YY = (this.bodies[i-1] as HTMLElement).offsetTop; // 将值设置为当前身体上 (this.bodies[i] as HTMLElement).style.left = XX + 'px'; (this.bodies[i] as HTMLElement).style.top = YY + 'px';