背景:
在使用TypeScript时,在vue中报了如上错误,“JSX 元素隐式具有类型 "any",因为不存在全局类型 "JSX.Element"。”
解决方法:
方法一
不使用严格的类型检查,即在 tsconfig.json 中设置 “strict”: false
{
"compilerOptions": {
"strict": false
}
}
方法二
在 tsconfig.json中设置 “noImplicitThis”: false
{
"compilerOptions": {
"noImplicitAny": false, // 是否在表达式和声明上有隐含的any类型时报错
}
}
备注:
本文参考:7b7d23d16ab5