mirror of
https://github.com/wahyd4/ant-design.git
synced 2026-08-20 10:16:17 +10:00
192 lines
46 KiB
HTML
192 lines
46 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="description" content="An enterprise-class UI design language and React-based implementation">
|
||
<meta name="description" content="A set of high-quality React components">
|
||
<meta name="description" content="One of best React UI library for enterprise background">
|
||
<title>Ant Design - A UI Design Language</title>
|
||
<script>
|
||
(function() {
|
||
function isLocalStorageNameSupported() {
|
||
const testKey = 'test';
|
||
const storage = window.localStorage;
|
||
try {
|
||
storage.setItem(testKey, '1');
|
||
storage.removeItem(testKey);
|
||
return true;
|
||
} catch (error) {
|
||
return false;
|
||
}
|
||
}
|
||
// 优先级提高到所有静态资源的前面,语言不对,加载其他静态资源没意义
|
||
var pathname = location.pathname;
|
||
|
||
function isZhCN(pathname) {
|
||
return /-cn\/?$/.test(pathname);
|
||
}
|
||
function getLocalizedPathname(path, zhCN) {
|
||
var pathname = path.startsWith('/') ? path : '/' + path;
|
||
if (!zhCN) { // to enUS
|
||
return /\/?index-cn/.test(pathname) ? '/' : pathname.replace('-cn', '');
|
||
} else if (pathname === '/') {
|
||
return '/index-cn';
|
||
} else if (pathname.endsWith('/')) {
|
||
return pathname.replace(/\/$/, '-cn/');
|
||
}
|
||
return pathname + '-cn';
|
||
}
|
||
|
||
// 兼容旧的 URL, `?locale=...`
|
||
var queryString = location.search;
|
||
if (queryString) {
|
||
var isZhCNConfig = queryString.indexOf('zh-CN') > -1;
|
||
if (isZhCNConfig && !isZhCN(pathname)) {
|
||
location.pathname = getLocalizedPathname(pathname, isZhCNConfig)
|
||
}
|
||
}
|
||
|
||
// 首页无视链接里面的语言设置 https://github.com/ant-design/ant-design/issues/4552
|
||
if (isLocalStorageNameSupported() && (pathname === '/' || pathname === '/index-cn')) {
|
||
var lang = (window.localStorage && localStorage.getItem('locale')) || navigator.language;
|
||
if ((lang === 'zh-CN') !== isZhCN(pathname)) {
|
||
location.pathname = getLocalizedPathname(pathname, lang === 'zh-CN');
|
||
}
|
||
}
|
||
document.documentElement.className += isZhCN(pathname) ? 'zh-cn' : 'en-us';
|
||
})()
|
||
</script>
|
||
<link rel="icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
|
||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.cnpmjs.org/css?family=Lato:400,700|Raleway"/>
|
||
<link rel="stylesheet" type="text/css" href="/index.css"/>
|
||
<style id="nprogress-style">
|
||
#nprogress { display: none }
|
||
</style>
|
||
<!--[if lte IE 10]>
|
||
<script
|
||
src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,media-match/2.0.2/media.match.min.js"></script>
|
||
<![endif]-->
|
||
<script>
|
||
if (!window.Intl) {
|
||
document.writeln('<script src="https://as.alipayobjects.com/g/component/intl/1.0.1/??Intl.js,locale-data/jsonp/en.js,locale-data/jsonp/zh.js">' + '<' + '/script>');
|
||
}
|
||
if (!window.Promise) {
|
||
document.writeln('<script src="https://as.alipayobjects.com/g/component/es6-promise/3.2.2/es6-promise.min.js"' + '>' + '<' + '/' + 'script>');
|
||
}
|
||
// Enable Google Analytics
|
||
if (!location.port) {
|
||
/* eslint-disable */
|
||
(function (i, s, o, g, r, a, m) {
|
||
i['GoogleAnalyticsObject'] = r;
|
||
i[r] = i[r] || function () {
|
||
(i[r].q = i[r].q || []).push(arguments)
|
||
}, i[r].l = 1 * new Date();
|
||
a = s.createElement(o),
|
||
m = s.getElementsByTagName(o)[0];
|
||
a.async = 1;
|
||
a.src = g;
|
||
m.parentNode.insertBefore(a, m)
|
||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||
ga('create', 'UA-72788897-1', 'auto');
|
||
ga('send', 'pageview');
|
||
/* eslint-enable */
|
||
}
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<div id="react-content">
|
||
<div class="page-wrapper" data-reactroot="" data-reactid="1" data-react-checksum="-1809087380"><header id="header" class="clearfix" data-reactid="2"><div class="ant-row" data-reactid="3"><div class="ant-col-xs-24 ant-col-sm-24 ant-col-md-5 ant-col-lg-4" data-reactid="4"><a id="logo" href="/" data-reactid="5"><img alt="logo" src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" data-reactid="6"/><span data-reactid="7">Ant Design</span></a></div><div class="ant-col-xs-0 ant-col-sm-0 ant-col-md-19 ant-col-lg-20" data-reactid="8"><div id="search-box" data-reactid="9"><div class="ant-select ant-select-combobox ant-select-enabled" data-reactid="10"><div class="ant-select-selection
|
||
ant-select-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" data-reactid="11"><div class="ant-select-selection__rendered" data-reactid="12"><div style="display:block;user-select:none;-webkit-user-select:none;" unselectable="unselectable" class="ant-select-selection__placeholder" data-reactid="13">Search Components...</div><ul data-reactid="14"><li class="ant-select-search ant-select-search--inline" data-reactid="15"><div class="ant-select-search__field__wrap" data-reactid="16"><input value="" class="ant-select-search__field" data-reactid="17"/><span class="ant-select-search__field__mirror" data-reactid="18"></span></div></li></ul></div><span class="ant-select-arrow" style="user-select:none;-webkit-user-select:none;" unselectable="unselectable" data-reactid="19"><b data-reactid="20"></b></span></div></div></div><button type="button" class="ant-btn ant-btn-ghost ant-btn-sm lang" data-reactid="21"><span data-reactid="22">中文</span></button><div class="ant-select-sm version ant-select ant-select-enabled" data-reactid="23"><div class="ant-select-selection
|
||
ant-select-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" tabindex="0" data-reactid="24"><div class="ant-select-selection__rendered" data-reactid="25"><div class="ant-select-selection-selected-value" title="2.7.3" style="display:block;opacity:1;" data-reactid="26">2.7.3</div></div><span class="ant-select-arrow" style="user-select:none;-webkit-user-select:none;" unselectable="unselectable" data-reactid="27"><b data-reactid="28"></b></span></div></div><ul class="ant-menu ant-menu-horizontal ant-menu-light ant-menu-root" role="menu" aria-activedescendant="" id="nav" tabindex="0" data-reactid="29"><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="30"><a href="/" data-reactid="31"><span data-reactid="32">Home</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="33"><a href="/docs/spec/introduce" data-reactid="34"><span data-reactid="35">Specification</span></a></li><li class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="36"><a href="/docs/react/introduce" data-reactid="37"><span data-reactid="38">Components</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="39"><a href="/docs/pattern/navigation" data-reactid="40"><span data-reactid="41">Pattern</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="42"><a href="/docs/practice/cases" data-reactid="43"><span data-reactid="44">Practice</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="45"><a href="/docs/resource/download" data-reactid="46"><span data-reactid="47">Resource</span></a></li></ul></div></div></header><div class="main-wrapper" data-reactid="48"><div class="ant-row" data-reactid="49"><div class="ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-4" data-reactid="50"><ul class="ant-menu ant-menu-inline aside-container ant-menu-light ant-menu-root" role="menu" aria-activedescendant="" tabindex="0" data-reactid="51"><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="52"><a href="/docs/react/introduce" data-reactid="53">Ant Design of React</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="54"><a href="/docs/react/getting-started" data-reactid="55">Getting Started</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="56"><a href="/docs/react/practical-projects" data-reactid="57">Real project with dva</a></li><li style="padding-left:24px;" class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="58"><a href="/docs/react/use-with-create-react-app" data-reactid="59">Use in create-react-app</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="60"><a href="/docs/react/customize-theme" data-reactid="61">Customize Theme</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="62"><a href="/changelog" data-reactid="63">Change Log</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="64"><a href="/docs/react/recommendation" data-reactid="65">Third-Party Library</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="66"><a href="https://github.com/websemantics/awesome-ant-design" target="_blank" rel="noopener noreferrer" class="menu-item-link-outside" data-reactid="67"><!-- react-text: 68 -->Awesome Ant Design<!-- /react-text --><!-- react-text: 69 --> <!-- /react-text --><i class="anticon anticon-export" data-reactid="70"></i></a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="71"><a href="//github.com/ant-design/intl-example" target="_blank" rel="noopener noreferrer" class="menu-item-link-outside" data-reactid="72"><!-- react-text: 73 -->i18n Solution<!-- /react-text --><!-- react-text: 74 --> <!-- /react-text --><i class="anticon anticon-export" data-reactid="75"></i></a></li><li class="ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu" data-reactid="76"><div style="padding-left:24px;" class="ant-menu-submenu-title" aria-expanded="true" aria-owns="Components$Menu" aria-haspopup="true" data-reactid="77"><h4 data-reactid="78">Components</h4></div><ul class="ant-menu ant-menu-inline ant-menu-sub" role="menu" aria-activedescendant="" id="Components$Menu" data-reactid="79"><li class=" ant-menu-item-group" data-reactid="80"><div class="ant-menu-item-group-title" data-reactid="81">General</div><ul class="ant-menu-item-group-list" data-reactid="82"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="83"><a href="/components/button/" data-reactid="84"><span data-reactid="85">Button</span><span class="chinese" data-reactid="86"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="87"><a href="/components/icon/" data-reactid="88"><span data-reactid="89">Icon</span><span class="chinese" data-reactid="90"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="91"><div class="ant-menu-item-group-title" data-reactid="92">Layout</div><ul class="ant-menu-item-group-list" data-reactid="93"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="94"><a href="/components/grid/" data-reactid="95"><span data-reactid="96">Grid</span><span class="chinese" data-reactid="97"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="98"><a href="/components/layout/" data-reactid="99"><span data-reactid="100">Layout</span><span class="chinese" data-reactid="101"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="102"><div class="ant-menu-item-group-title" data-reactid="103">Navigation</div><ul class="ant-menu-item-group-list" data-reactid="104"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="105"><a href="/components/affix/" data-reactid="106"><span data-reactid="107">Affix</span><span class="chinese" data-reactid="108"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="109"><a href="/components/breadcrumb/" data-reactid="110"><span data-reactid="111">Breadcrumb</span><span class="chinese" data-reactid="112"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="113"><a href="/components/back-top/" data-reactid="114"><span data-reactid="115">BackTop</span><span class="chinese" data-reactid="116"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="117"><a href="/components/dropdown/" data-reactid="118"><span data-reactid="119">Dropdown</span><span class="chinese" data-reactid="120"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="121"><a href="/components/menu/" data-reactid="122"><span data-reactid="123">Menu</span><span class="chinese" data-reactid="124"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="125"><a href="/components/pagination/" data-reactid="126"><span data-reactid="127">Pagination</span><span class="chinese" data-reactid="128"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="129"><a href="/components/steps/" data-reactid="130"><span data-reactid="131">Steps</span><span class="chinese" data-reactid="132"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="133"><a href="/components/tabs/" data-reactid="134"><span data-reactid="135">Tabs</span><span class="chinese" data-reactid="136"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="137"><div class="ant-menu-item-group-title" data-reactid="138">Data Entry</div><ul class="ant-menu-item-group-list" data-reactid="139"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="140"><a href="/components/auto-complete/" data-reactid="141"><span data-reactid="142">AutoComplete</span><span class="chinese" data-reactid="143"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="144"><a href="/components/cascader/" data-reactid="145"><span data-reactid="146">Cascader</span><span class="chinese" data-reactid="147"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="148"><a href="/components/checkbox/" data-reactid="149"><span data-reactid="150">Checkbox</span><span class="chinese" data-reactid="151"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="152"><a href="/components/date-picker/" data-reactid="153"><span data-reactid="154">DatePicker</span><span class="chinese" data-reactid="155"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="156"><a href="/components/form/" data-reactid="157"><span data-reactid="158">Form</span><span class="chinese" data-reactid="159"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="160"><a href="/components/input/" data-reactid="161"><span data-reactid="162">Input</span><span class="chinese" data-reactid="163"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="164"><a href="/components/input-number/" data-reactid="165"><span data-reactid="166">InputNumber</span><span class="chinese" data-reactid="167"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="168"><a href="/components/mention/" data-reactid="169"><span data-reactid="170">Mention</span><span class="chinese" data-reactid="171"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="172"><a href="/components/rate/" data-reactid="173"><span data-reactid="174">Rate</span><span class="chinese" data-reactid="175"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="176"><a href="/components/radio/" data-reactid="177"><span data-reactid="178">Radio</span><span class="chinese" data-reactid="179"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="180"><a href="/components/select/" data-reactid="181"><span data-reactid="182">Select</span><span class="chinese" data-reactid="183"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="184"><a href="/components/slider/" data-reactid="185"><span data-reactid="186">Slider</span><span class="chinese" data-reactid="187"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="188"><a href="/components/switch/" data-reactid="189"><span data-reactid="190">Switch</span><span class="chinese" data-reactid="191"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="192"><a href="/components/tree-select/" data-reactid="193"><span data-reactid="194">TreeSelect</span><span class="chinese" data-reactid="195"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="196"><a href="/components/time-picker/" data-reactid="197"><span data-reactid="198">TimePicker</span><span class="chinese" data-reactid="199"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="200"><a href="/components/transfer/" data-reactid="201"><span data-reactid="202">Transfer</span><span class="chinese" data-reactid="203"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="204"><a href="/components/upload/" data-reactid="205"><span data-reactid="206">Upload</span><span class="chinese" data-reactid="207"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="208"><div class="ant-menu-item-group-title" data-reactid="209">Data Display</div><ul class="ant-menu-item-group-list" data-reactid="210"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="211"><a href="/components/badge/" data-reactid="212"><span data-reactid="213">Badge</span><span class="chinese" data-reactid="214"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="215"><a href="/components/calendar/" data-reactid="216"><span data-reactid="217">Calendar</span><span class="chinese" data-reactid="218"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="219"><a href="/components/card/" data-reactid="220"><span data-reactid="221">Card</span><span class="chinese" data-reactid="222"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="223"><a href="/components/carousel/" data-reactid="224"><span data-reactid="225">Carousel</span><span class="chinese" data-reactid="226"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="227"><a href="/components/collapse/" data-reactid="228"><span data-reactid="229">Collapse</span><span class="chinese" data-reactid="230"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="231"><a href="/components/popover/" data-reactid="232"><span data-reactid="233">Popover</span><span class="chinese" data-reactid="234"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="235"><a href="/components/tooltip/" data-reactid="236"><span data-reactid="237">Tooltip</span><span class="chinese" data-reactid="238"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="239"><a href="/components/table/" data-reactid="240"><span data-reactid="241">Table</span><span class="chinese" data-reactid="242"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="243"><a href="/components/tag/" data-reactid="244"><span data-reactid="245">Tag</span><span class="chinese" data-reactid="246"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="247"><a href="/components/timeline/" data-reactid="248"><span data-reactid="249">Timeline</span><span class="chinese" data-reactid="250"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="251"><a href="/components/tree/" data-reactid="252"><span data-reactid="253">Tree</span><span class="chinese" data-reactid="254"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="255"><div class="ant-menu-item-group-title" data-reactid="256">Feedback</div><ul class="ant-menu-item-group-list" data-reactid="257"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="258"><a href="/components/alert/" data-reactid="259"><span data-reactid="260">Alert</span><span class="chinese" data-reactid="261"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="262"><a href="/components/modal/" data-reactid="263"><span data-reactid="264">Modal</span><span class="chinese" data-reactid="265"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="266"><a href="/components/message/" data-reactid="267"><span data-reactid="268">Message</span><span class="chinese" data-reactid="269"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="270"><a href="/components/notification/" data-reactid="271"><span data-reactid="272">Notification</span><span class="chinese" data-reactid="273"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="274"><a href="/components/progress/" data-reactid="275"><span data-reactid="276">Progress</span><span class="chinese" data-reactid="277"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="278"><a href="/components/popconfirm/" data-reactid="279"><span data-reactid="280">Popconfirm</span><span class="chinese" data-reactid="281"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="282"><a href="/components/spin/" data-reactid="283"><span data-reactid="284">Spin</span><span class="chinese" data-reactid="285"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="286"><div class="ant-menu-item-group-title" data-reactid="287">Other</div><ul class="ant-menu-item-group-list" data-reactid="288"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="289"><a href="/components/anchor/" data-reactid="290"><span data-reactid="291">Anchor</span><span class="chinese" data-reactid="292"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="293"><a href="/components/locale-provider/" data-reactid="294"><span data-reactid="295">LocaleProvider</span><span class="chinese" data-reactid="296"></span></a></li></ul></li></ul></li></ul></div><div class="main-container ant-col-xs-24 ant-col-sm-24 ant-col-md-18 ant-col-lg-20" data-reactid="297"><article class="markdown" data-reactid="298"><h1 data-reactid="299"><!-- react-text: 300 -->Use in create-react-app<!-- /react-text --><a class="edit-button" href="https://github.com/ant-design/ant-design/edit/master/docs/react/use-with-create-react-app.en-US.md" data-reactid="301"><i class="anticon anticon-edit" data-reactid="302"></i></a></h1><section class="markdown" data-reactid="303"><p data-reactid="304"><a href="https://github.com/facebookincubator/create-react-app" data-reactid="305"><!-- react-text: 306 -->create-react-app<!-- /react-text --></a><!-- react-text: 307 --> is one of best React application development tool, we are going to use <!-- /react-text --><code data-reactid="308"><!-- react-text: 309 -->antd<!-- /react-text --></code><!-- react-text: 310 --> within it and modify the webpack config for some customized needs.<!-- /react-text --></p></section><section class="toc" data-reactid="311"><ul data-reactid="312"><li data-reactid="313"><a class="bisheng-toc-h2" href="#Install-and-Initialization" data-reactid="314"><!-- react-text: 315 -->Install and Initialization<!-- /react-text --></a></li><li data-reactid="316"><a class="bisheng-toc-h2" href="#Import-antd" data-reactid="317"><!-- react-text: 318 -->Import antd<!-- /react-text --></a></li><li data-reactid="319"><a class="bisheng-toc-h2" href="#Advanced-Guides" data-reactid="320"><!-- react-text: 321 -->Advanced Guides<!-- /react-text --></a></li></ul></section><section class="markdown" data-reactid="322"><h2 id="Install-and-Initialization" data-reactid="323"><span data-reactid="324"><!-- react-text: 325 -->Install and Initialization<!-- /react-text --></span><a href="#Install-and-Initialization" class="anchor" data-reactid="326">#</a></h2><p data-reactid="327"><!-- react-text: 328 -->We need to install <!-- /react-text --><code data-reactid="329"><!-- react-text: 330 -->create-react-app<!-- /react-text --></code><!-- react-text: 331 --> first, you may need install <!-- /react-text --><a href="https://github.com/yarnpkg/yarn/" data-reactid="332"><!-- react-text: 333 -->yarn<!-- /react-text --></a><!-- react-text: 334 --> too.<!-- /react-text --></p><pre class="language-bash" data-reactid="335"><code data-reactid="336">$ <span class="token function">npm</span> <span class="token function">install</span> -g create-react-app yarn</code></pre><p data-reactid="337"><!-- react-text: 338 -->Create a new project named <!-- /react-text --><code data-reactid="339"><!-- react-text: 340 -->antd-demo<!-- /react-text --></code><!-- react-text: 341 -->.<!-- /react-text --></p><pre class="language-bash" data-reactid="342"><code data-reactid="343">$ create-react-app antd-demo</code></pre><p data-reactid="344"><!-- react-text: 345 -->The tool will create and initialize environment and dependencies automaticly,
|
||
please try config your proxy setting or use other npm registry if any network errors happen during it.<!-- /react-text --></p><p data-reactid="346"><!-- react-text: 347 -->Then we go inside <!-- /react-text --><code data-reactid="348"><!-- react-text: 349 -->antd-demo<!-- /react-text --></code><!-- react-text: 350 --> and start it.<!-- /react-text --></p><pre class="language-bash" data-reactid="351"><code data-reactid="352">$ <span class="token function">cd</span> antd-demo
|
||
$ yarn start</code></pre><p data-reactid="353"><!-- react-text: 354 -->Open browser at <!-- /react-text --><a href="http://localhost:3000/" data-reactid="355"><!-- react-text: 356 -->http://localhost:3000/<!-- /react-text --></a><!-- react-text: 357 -->, it renders a header saying "Welcome to React" on the page.<!-- /react-text --></p><h2 id="Import-antd" data-reactid="358"><span data-reactid="359"><!-- react-text: 360 -->Import antd<!-- /react-text --></span><a href="#Import-antd" class="anchor" data-reactid="361">#</a></h2><p data-reactid="362"><!-- react-text: 363 -->It is the default directory structure below.<!-- /react-text --></p><pre class="language-null" data-reactid="364"><code data-reactid="365">├── README<span class="token punctuation">.</span>md
|
||
├── package<span class="token punctuation">.</span>json
|
||
├── public
|
||
│ ├── favicon<span class="token punctuation">.</span>ico
|
||
│ └── index<span class="token punctuation">.</span>html
|
||
├── src
|
||
│ ├── App<span class="token punctuation">.</span>css
|
||
│ ├── App<span class="token punctuation">.</span>js
|
||
│ ├── App<span class="token punctuation">.</span>test<span class="token punctuation">.</span>js
|
||
│ ├── index<span class="token punctuation">.</span>css
|
||
│ ├── index<span class="token punctuation">.</span>js
|
||
│ └── logo<span class="token punctuation">.</span>svg
|
||
└── yarn<span class="token punctuation">.</span>lock</code></pre><p data-reactid="366"><!-- react-text: 367 -->Now we install <!-- /react-text --><code data-reactid="368"><!-- react-text: 369 -->antd<!-- /react-text --></code><!-- react-text: 370 --> from yarn or npm.<!-- /react-text --></p><pre class="language-bash" data-reactid="371"><code data-reactid="372">$ yarn add antd --save</code></pre><p data-reactid="373"><!-- react-text: 374 -->Modify <!-- /react-text --><code data-reactid="375"><!-- react-text: 376 -->src/App.js<!-- /react-text --></code><!-- react-text: 377 -->, import Button component from <!-- /react-text --><code data-reactid="378"><!-- react-text: 379 -->antd<!-- /react-text --></code><!-- react-text: 380 -->.<!-- /react-text --></p><pre class="language-jsx" data-reactid="381"><code data-reactid="382"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
|
||
<span class="token keyword">import</span> <span class="token punctuation">{</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'antd'</span><span class="token punctuation">;</span>
|
||
<span class="token keyword">import</span> <span class="token string">'./App.css'</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
|
||
<span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">return</span> <span class="token punctuation">(</span>
|
||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>App<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
|
||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Button<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>
|
||
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
|
||
<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
<span class="token punctuation">}</span>
|
||
|
||
<span class="token keyword">export</span> <span class="token keyword">default</span> App<span class="token punctuation">;</span></code></pre><p data-reactid="383"><!-- react-text: 384 -->Add <!-- /react-text --><code data-reactid="385"><!-- react-text: 386 -->antd/dist/antd.css<!-- /react-text --></code><!-- react-text: 387 --> at the top of <!-- /react-text --><code data-reactid="388"><!-- react-text: 389 -->src/App.css<!-- /react-text --></code><!-- react-text: 390 -->.<!-- /react-text --></p><pre class="language-css" data-reactid="391"><code data-reactid="392"><span class="token atrule"><span class="token rule">@import</span> <span class="token string">'~antd/dist/antd.css'</span><span class="token punctuation">;</span></span>
|
||
|
||
<span class="token selector"><span class="token class">.App</span> </span><span class="token punctuation">{</span>
|
||
<span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
|
||
<span class="token number">...</span></code></pre><p data-reactid="393"><!-- react-text: 394 -->Ok, you now see a blue primary button displaying in page now, next you can choose any components of <!-- /react-text --><code data-reactid="395"><!-- react-text: 396 -->antd<!-- /react-text --></code><!-- react-text: 397 --> to develop your application. Visit other workflow of <!-- /react-text --><code data-reactid="398"><!-- react-text: 399 -->create-react-app<!-- /react-text --></code><!-- react-text: 400 --> at its <!-- /react-text --><a href="https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md" data-reactid="401"><!-- react-text: 402 -->User Guide <!-- /react-text --></a><!-- react-text: 403 -->.<!-- /react-text --></p><h2 id="Advanced-Guides" data-reactid="404"><span data-reactid="405"><!-- react-text: 406 -->Advanced Guides<!-- /react-text --></span><a href="#Advanced-Guides" class="anchor" data-reactid="407">#</a></h2><p data-reactid="408"><!-- react-text: 409 -->We are successd to run antd components now, but in the real world, there are still lots of problems about antd-demo.
|
||
For instance, we actully import all components in the project which will be a serious network perfermance issue.<!-- /react-text --></p><blockquote data-reactid="410"><p data-reactid="411"><!-- react-text: 412 -->You will see a warning in your browser console.
|
||
<!-- /react-text --><img src="https://zos.alipayobjects.com/rmsportal/vgcHJRVZFmPjAawwVoXK.png" data-reactid="413"/></p></blockquote><p data-reactid="414"><!-- react-text: 415 -->So it is necessary to customize the default webpack config. We can achieve that by using <!-- /react-text --><code data-reactid="416"><!-- react-text: 417 -->eject<!-- /react-text --></code><!-- react-text: 418 --> script command.<!-- /react-text --></p><pre class="language-bash" data-reactid="419"><code data-reactid="420">$ yarn run <span class="token function">eject</span></code></pre><h3 id="Import-on-demand" data-reactid="421"><span data-reactid="422"><!-- react-text: 423 -->Import on demand<!-- /react-text --></span><a href="#Import-on-demand" class="anchor" data-reactid="424">#</a></h3><p data-reactid="425"><a href="https://github.com/ant-design/babel-plugin-import" data-reactid="426"><!-- react-text: 427 -->babel-plugin-import<!-- /react-text --></a><!-- react-text: 428 --> is a babel plugin for importing components on demand (<!-- /react-text --><a href="/docs/react/getting-started#Import-on-Demand" data-reactid="429">principle</a><!-- react-text: 430 -->). After eject all config files to antd-demo, we allowed to install it and modify <!-- /react-text --><code data-reactid="431"><!-- react-text: 432 -->config/webpack.config.dev.js<!-- /react-text --></code><!-- react-text: 433 --> now.<!-- /react-text --></p><pre class="language-bash" data-reactid="434"><code data-reactid="435">$ yarn add babel-plugin-import --save-dev</code></pre><pre class="language-diff" data-reactid="436"><code data-reactid="437">// Process JS with Babel.
|
||
{
|
||
test: /\.(js|jsx)$/,
|
||
include: paths.appSrc,
|
||
loader: 'babel',
|
||
query: {
|
||
<span class="token inserted">+ plugins: [</span>
|
||
<span class="token inserted">+ ['import', [{ libraryName: "antd", style: 'css' }]],</span>
|
||
<span class="token inserted">+ ],</span>
|
||
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
||
// It enables caching results in ./node_modules/.cache/babel-loader/
|
||
// directory for faster rebuilds.
|
||
cacheDirectory: true
|
||
}
|
||
},</code></pre><blockquote data-reactid="438"><p data-reactid="439"><!-- react-text: 440 -->Note: because there is no <!-- /react-text --><code data-reactid="441"><!-- react-text: 442 -->.babelrc<!-- /react-text --></code><!-- react-text: 443 --> file after config eject, so we have to put the babel option into <!-- /react-text --><code data-reactid="444"><!-- react-text: 445 -->webpack.config.js<!-- /react-text --></code><!-- react-text: 446 --> or <!-- /react-text --><code data-reactid="447"><!-- react-text: 448 -->babel<!-- /react-text --></code><!-- react-text: 449 --> field of <!-- /react-text --><code data-reactid="450"><!-- react-text: 451 -->package.json<!-- /react-text --></code><!-- react-text: 452 -->.<!-- /react-text --></p></blockquote><p data-reactid="453"><!-- react-text: 454 -->Remove the <!-- /react-text --><code data-reactid="455"><!-- react-text: 456 -->@import '~antd/dist/antd.css';<!-- /react-text --></code><!-- react-text: 457 --> statement added before because <!-- /react-text --><code data-reactid="458"><!-- react-text: 459 -->babel-plugin-import<!-- /react-text --></code><!-- react-text: 460 --> will import styles.<!-- /react-text --></p><p data-reactid="461"><!-- react-text: 462 -->Then reboot <!-- /react-text --><code data-reactid="463"><!-- react-text: 464 -->yarn start<!-- /react-text --></code><!-- react-text: 465 --> and visit demo page, you should find that the above warning message would be gone which prove the <!-- /react-text --><code data-reactid="466"><!-- react-text: 467 -->import on demand<!-- /react-text --></code><!-- react-text: 468 --> config is effective now.<!-- /react-text --></p><h3 id="Customize-Theme" data-reactid="469"><span data-reactid="470"><!-- react-text: 471 -->Customize Theme<!-- /react-text --></span><a href="#Customize-Theme" class="anchor" data-reactid="472">#</a></h3><p data-reactid="473"><!-- react-text: 474 -->According to <!-- /react-text --><a href="/docs/react/customize-theme" data-reactid="475">Customize Theme documentation</a><!-- react-text: 476 -->, we need <!-- /react-text --><code data-reactid="477"><!-- react-text: 478 -->less<!-- /react-text --></code><!-- react-text: 479 --> variables modify ability of <!-- /react-text --><a href="https://github.com/webpack/less-loader" data-reactid="480"><!-- react-text: 481 -->less-loader<!-- /react-text --></a><!-- react-text: 482 -->, so we add it.<!-- /react-text --></p><pre class="language-bash" data-reactid="483"><code data-reactid="484">$ yarn add <span class="token function">less</span> less-loader --save-dev</code></pre><pre class="language-diff" data-reactid="485"><code data-reactid="486">loaders: [
|
||
{
|
||
exclude: [
|
||
/\.html$/,
|
||
/\.(js|jsx)$/,
|
||
<span class="token inserted">+ /\.less$/,</span>
|
||
/\.css$/,
|
||
/\.json$/,
|
||
/\.svg$/
|
||
],
|
||
loader: 'url',
|
||
},
|
||
|
||
...
|
||
|
||
// Process JS with Babel.
|
||
{
|
||
test: /\.(js|jsx)$/,
|
||
include: paths.appSrc,
|
||
loader: 'babel',
|
||
query: {
|
||
plugins: [
|
||
<span class="token deleted">- ['import', [{ libraryName: "antd", style: 'css' }]],</span>
|
||
<span class="token inserted">+ ['import', [{ libraryName: "antd", style: true }]], // import less</span>
|
||
],
|
||
},
|
||
|
||
...
|
||
|
||
<span class="token inserted">+ // Parse less files and modify variables</span>
|
||
<span class="token inserted">+ {</span>
|
||
<span class="token inserted">+ test: /\.less$/,</span>
|
||
<span class="token inserted">+ loader: 'style!css!postcss!less?{modifyVars:{"@primary-color":"#1DA57A"}}'</span>
|
||
<span class="token inserted">+ },</span>
|
||
]</code></pre><p data-reactid="487"><!-- react-text: 488 -->We use <!-- /react-text --><code data-reactid="489"><!-- react-text: 490 -->modifyVars<!-- /react-text --></code><!-- react-text: 491 --> option of <!-- /react-text --><a href="https://github.com/webpack/less-loader#less-options" data-reactid="492"><!-- react-text: 493 -->less-loader<!-- /react-text --></a><!-- react-text: 494 --> here, you can see a green button rendered on the page after reboot start server.<!-- /react-text --></p><hr data-reactid="495"/><p data-reactid="496"><!-- react-text: 497 -->Finally, we use antd with create-react-app successfully, you can learn these practice for your own webpack workflow too, and find more webpack config in the <!-- /react-text --><a href="https://github.com/ant-tool/atool-build/blob/master/src/getWebpackCommonConfig.js" data-reactid="498"><!-- react-text: 499 -->atool-build<!-- /react-text --></a><!-- react-text: 500 -->. (For instance, add <!-- /react-text --><a href="https://github.com/ant-tool/atool-build/blob/e4bd2959689b6a95cb5c1c854a5db8c98676bdb3/src/getWebpackCommonConfig.js#L90" data-reactid="501"><!-- react-text: 502 -->moment noParse<!-- /react-text --></a><!-- react-text: 503 --> to avoid loading all language files)<!-- /react-text --></p><p data-reactid="504"><!-- react-text: 505 -->Source code about this article:<!-- /react-text --><a href="https://github.com/ant-design/create-react-app-antd" data-reactid="506"><!-- react-text: 507 -->https://github.com/ant-design/create-react-app-antd<!-- /react-text --></a></p></section></article></div></div><div class="ant-row" data-reactid="508"><div class="ant-col-xs-24 ant-col-sm-24 ant-col-md-18 ant-col-md-offset-6 ant-col-lg-20 ant-col-lg-offset-4" data-reactid="509"><section class="prev-next-nav" data-reactid="510"><a class="prev-page" href="/docs/react/practical-projects" data-reactid="511">Real project with dva</a><a class="next-page" href="/docs/react/customize-theme" data-reactid="512">Customize Theme</a></section></div></div></div><footer id="footer" data-reactid="513"><ul data-reactid="514"><li data-reactid="515"><h2 data-reactid="516"><i class="anticon anticon-github" data-reactid="517"></i><!-- react-text: 518 --> GitHub<!-- /react-text --></h2><div data-reactid="519"><a target="_blank " href="https://github.com/ant-design/ant-design" data-reactid="520"><span data-reactid="521">Repository</span></a></div><div data-reactid="522"><a target="_blank " href="https://ant.design/docs/react/customize-theme" data-reactid="523"><span data-reactid="524">Customize Theme</span></a></div><div data-reactid="525"><a target="_blank " href="https://github.com/websemantics/awesome-ant-design" data-reactid="526"><span data-reactid="527">Awesome Ant Design</span></a></div></li><li data-reactid="528"><h2 data-reactid="529"><i class="anticon anticon-link" data-reactid="530"></i><!-- react-text: 531 --> <!-- /react-text --><span data-reactid="532">Links</span></h2><div data-reactid="533"><a href="http://mobile.ant.design" data-reactid="534">Ant Design Mobile</a><span data-reactid="535"> - </span><span data-reactid="536">Mobile UI</span></div><div data-reactid="537"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva" data-reactid="538">dva</a><!-- react-text: 539 --> - <!-- /react-text --><span data-reactid="540">Framework</span></div><div data-reactid="541"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva-cli" data-reactid="542">dva-cli</a><!-- react-text: 543 --> -<!-- /react-text --><span data-reactid="544">Developer Tools</span></div><div data-reactid="545"><a href="https://antv.alipay.com/" data-reactid="546">AntV</a><span data-reactid="547"> - </span><span data-reactid="548">Data Visualization</span></div><div data-reactid="549"><a href="http://motion.ant.design" data-reactid="550">Ant Motion</a><span data-reactid="551"> - </span><span data-reactid="552">Motion Soluction</span></div><div data-reactid="553"><a href="http://library.ant.design/" data-reactid="554">AntD Library</a><span data-reactid="555"> - </span><span data-reactid="556">Axure library</span></div><div data-reactid="557"><a href="http://ux.ant.design" data-reactid="558">Ant UX</a><span data-reactid="559"> - </span><span data-reactid="560">Sitemap Template</span></div></li><li data-reactid="561"><h2 data-reactid="562"><i class="anticon anticon-customer-service" data-reactid="563"></i><!-- react-text: 564 --> <!-- /react-text --><span data-reactid="565">Community</span></h2><div data-reactid="566"><a rel="noopener noreferrer" href="/changelog" data-reactid="567"><span data-reactid="568">Change Log</span></a></div><div data-reactid="569"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/wiki/FAQ" data-reactid="570"><span data-reactid="571">FAQ</span></a></div><div data-reactid="572"><a target="_blank" rel="noopener noreferrer" href="https://gitter.im/ant-design/ant-design" data-reactid="573"><span data-reactid="574">Chat Room</span></a></div><div data-reactid="575"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/issues/new" data-reactid="576"><span data-reactid="577">Bug Report</span></a></div><div data-reactid="578"><a target="_blank" rel="noopener noreferrer" href="http://stackoverflow.com/questions/tagged/antd" data-reactid="579"><span data-reactid="580">StackOverflow</span></a></div><div data-reactid="581"><a target="_blank" rel="noopener noreferrer" href="https://segmentfault.com/t/antd" data-reactid="582"><span data-reactid="583">SegmentFault</span></a></div></li><li data-reactid="584"><h2 data-reactid="585">Copyright © 2017</h2><div data-reactid="586"><span data-reactid="587">Created by Ant UED</span></div><div data-reactid="588"><!-- react-text: 589 -->Built with <!-- /react-text --><a href="https://github.com/benjycui/bisheng" data-reactid="590">BiSheng</a></div></li></ul></footer></div>
|
||
</div>
|
||
<script src="/common.js"></script>
|
||
<script src="/index.js"></script>
|
||
</body>
|
||
</html>
|