Ticker

6/recent/ticker-posts

Ad Code

Responsive Advertisement

typescript元组自动转换问题

interface v{
    a:string,
    b:[string|number,string|boolean]
}
const x:v={
    a:'xxxx',
    b:[1,true]
}

在vue+Typescript项目中,然后到使用x这个变量的时候b[0]的值就被强制转换成了true,但是我想要的是number的类型(没有在其他地方重新赋值),有没有大佬知道是什么问题,或者解决办法是什么

Enregistrer un commentaire

0 Commentaires