首页 前端知识 【Typescript antd】安装了antd后,报错找不到antd模块(已解决)

【Typescript antd】安装了antd后,报错找不到antd模块(已解决)

2024-10-30 21:10:16 前端知识 前端哥 434 697 我要收藏

当前默认版本
"antd": "^5.3.3"

使用框架
react

辅助语言
typescript

报错:
在这里插入图片描述
代码:

import React from 'react';
import type { FC } from 'react';
// 这里找不到antd模块
import { Button } from 'antd';
import 'antd/dist/reset.css';
const App: FC = () => (
<div className="App">
<Button type="primary">Button</Button>
</div>
);
export default App;
复制

解决
按照报错提示,在tsconfig.json中添加配置

{
"compilerOptions": {
// 解决找不到xxx模块的问题
"moduleResolution": "node",
}
}
复制

好了,错误消失。

转载请注明出处或者链接地址:https://www.qianduange.cn//article/19673.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!