日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Ant Design使用方法

發(fā)布時(shí)間:2025/3/20 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ant Design使用方法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.antd官網(wǎng):

https://ant.design/docs/react/introduce-cn

2、React中使用Antd

  1、安裝antd npm install antd --save / yarn add antd / cnpm install antd --save2、在您的react項(xiàng)目的css文件中引入 Antd的css@import '~antd/dist/antd.css';

3、看文檔使用:

如使用Button:1、在對(duì)應(yīng)的組件中引入Antd import { Button } from 'antd';2、<Button type="primary">Primary</Button>

4、React中使用Antd高級(jí)配置,按需引入css樣式(該步驟在一定程度上提高用戶體驗(yàn),但也可以不配置)

我們現(xiàn)在已經(jīng)把組件成功運(yùn)行起來了,但是在實(shí)際開發(fā)過程中還有很多問題,例如上面的例子實(shí)際上加載了全部的 antd 組件的樣式(對(duì)前端性能是個(gè)隱患)。 1、安裝antd npm install antd --save2、安裝(react-app-rewired)一個(gè)對(duì) create-react-app 進(jìn)行自定義配置的社區(qū)解決方案yarn add react-app-rewired / cnpm install react-app-rewired --save3、修改 package.jsonreact-scripts 需改為react-app-rewired"scripts": {"start": "react-app-rewired start","build": "react-app-rewired build","test": "react-app-rewired test --env=jsdom","eject": "react-app-rewired eject"}4、安裝babel-plugin-import babel-plugin-import是一個(gè)用于按需加載組件代碼和樣式的 babel 插件yarn add babel-plugin-import / cnpm install babel-plugin-import --save5、在項(xiàng)目根目錄創(chuàng)建一個(gè) config-overrides.js 配置文件const { injectBabelPlugin } = require('react-app-rewired');module.exports = function override(config, env) {config = injectBabelPlugin(['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],config,);return config;};6、然后移除前面在 src/App.css 里全量添加的 @import '~antd/dist/antd.css'; 直接引入組件使用就會(huì)有對(duì)應(yīng)的cssimport { Button } from 'antd';<Button type="primary">Primary</Button>

?

轉(zhuǎn)載于:https://www.cnblogs.com/ywjfx/p/10435404.html

總結(jié)

以上是生活随笔為你收集整理的Ant Design使用方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。