简体   繁体   English

与 typescript 项目反应的国家标志

[英]react country flag in react with typescript project

Hey I am recently working with react and typescript together and I wanted to have some country logos, I installed this package which seems to be the most popular one for reactjs, the package called react country flag, and I cannot use it maybe with ts? Hey I am recently working with react and typescript together and I wanted to have some country logos, I installed this package which seems to be the most popular one for reactjs, the package called react country flag, and I cannot use it maybe with ts? is that the case?是这样吗? my error is the one in the image below.我的错误是下图中的错误。

在此处输入图像描述

The package does not come with typescript types, do this in the terminal. package 不附带 typescript 类型,请在终端中执行此操作。 This will try to download the types for that package if they exist这将尝试下载该 package 的类型(如果存在)

npm i --save-dev @types/react-country-flag

If it still doesn't exist, add如果它仍然不存在,请添加

//@ts-ignore above the import line, like this: //@ts-ignore 在导入行上方,像这样:

//@ts-ignore
import ReactCountryFlag from "react-country-flag"

That will ignore the error you are having这将忽略您遇到的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM