1 2 3 4 5 6 |
for (x in browserPrefix) { if (el.style[x] !== undefined) { // ^---- [TS Error]: Element has 'any' type b/c index expression is not of type 'number' return browserPrefix[x]; } } |
就是上面的代码报的错:
解决:
1 2 3 4 5 |
for (x in browserPrefix) { if (el.style[x as any] !== undefined) { return browserPrefix[x]; } } |
给个any类型就行
[x as any]