react+antd项目搭建
时间: 2023-09-01 09:11:36 浏览: 133
搭建 React Antd 项目可以按照以下步骤进行:
1. 创建 React 项目
首先,你需要创建一个 React 项目。你可以使用 create-react-app 生成器来创建项目。可以按照以下命令来创建:
```
npx create-react-app my-app
```
2. 安装 Antd
在你的项目目录下,运行以下命令安装 Antd:
```
npm install antd --save
```
3. 引入 Antd 样式
在你的项目入口文件(通常是 src/index.js 或 src/index.tsx)中,引入 Antd 的样式文件:
```javascript
import 'antd/dist/antd.css';
```
4. 使用 Antd 组件
现在你可以在你的项目中使用 Antd 组件了。例如,你可以在 src/App.js 中添加一个 Button 组件:
```javascript
import React from 'react';
import { Button } from 'antd';
function App() {
return (
<div className="App">
<Button type="primary">Button</Button>
</div>
);
}
export default App;
```
5. 运行你的项目
现在运行你的项目,可以使用以下命令来启动:
```
npm start
```
这些就是搭建 Antd 项目的基本步骤。你可以根据你的需求来添加更多的 Antd 组件,并使用它们来构建你的 React 应用程序。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)