網(wǎng)站首頁 編程語言 正文
0.前言
我們在后臺管理系統(tǒng)React項目開發(fā)中會有Table表格、Form表單、List列表、Button按鈕等組件,這個時候我們可以使用AntDesign來減少開發(fā)中不必要的樣式問題。
1.AntDesign是什么?
Ant Design 是一個 UI 設計語言,是一套提煉和應用于企業(yè)級后臺產(chǎn)品的交互語言和視覺體系
2.AntDesign如何使用?
首先你要安裝 yarn
或npm
或cnpm
$ yarn create react-app antd-demo # or $ npx create-react-app antd-demo # or $ npm create react-app antd-demo // 若網(wǎng)絡緩慢可使用cnpm淘寶鏡像 $ cnpm create react-app antd-demo
工具會自動初始化一個腳手架并安裝 React 項目的各種必要依賴
然后我們進入項目并啟動。
$ cd antd-demo $ yarn/npm/cnpm start
此時瀏覽器會訪問?http://localhost:3000/?,看到?Welcome to React
?的界面就算成功了。
而后需要引入AntD
現(xiàn)在從 yarn 或 npm 安裝并引入 antd。
$ yarn add antd
3.如何具體使用AntDdesign的組件
通用步驟是,先用import引入antd的具體某一個組件,然后根據(jù)規(guī)則及API使用
例:
3-1.如何使用 antd 的Table組件
import React from 'react'; import { Table } from 'antd'; import './App.css'; const columns = [ { title: 'Name', dataIndex: 'name', key: 'name', render: text => <a>{text}</a>, }, { title: 'Age', dataIndex: 'age', key: 'age', }, ]; const data = [ { key: 1, name: 'one', age: '10', }, { key: 2, name: 'two', age: '20', }, ]; const App = () => ( <div className="App"> <Table columns={columns} dataSource={data} /> </div> ); export default App;
樣式如圖:
3-2.如何使用 antd 的Button組件
import React from 'react'; import { Button } from 'antd'; const App = () => ( <div className="App"> <Button type="primary">Primary Button</Button><br/> <Button>Default Button</Button><br/> <Button type="dashed">Dashed Button</Button><br/> <Button type="text">Text Button</Button><br/> <Button type="link">Link Button</Button><br/> </div> ); export default App;
4.后續(xù)
總結(jié):總體來說要使用ant具體的某一個組件,就要仔細觀看組件的API,以API為基準來進行開發(fā)。
好處:用Ant開發(fā),省去了寫css樣式的問題,同時,組件里也有相應的JS方法,便于開發(fā)
原文鏈接:https://juejin.cn/post/7085170302170202142
相關推薦
- 2022-06-23 Python在畫圖時使用特殊符號的方法總結(jié)_python
- 2023-07-27 修改el-button 的樣式
- 2023-01-30 react-router-dom?降低版本的兩種方法詳解_React
- 2022-11-27 搭建?Selenium+Python開發(fā)環(huán)境詳細步驟_python
- 2022-08-21 Android自定義view貝塞爾曲線_Android
- 2022-05-25 如何把自己寫的jar包打進本地maven倉庫呢(也是springboot項目怎么打成SDK)
- 2022-06-04 Android基于Fresco實現(xiàn)圓角和圓形圖片_Android
- 2023-06-21 ProtoBuf動態(tài)拆分Gradle?Module解析_Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支