mirror of
https://github.com/wahyd4/ant-design.git
synced 2026-08-13 23:07:49 +10:00
168 lines
43 KiB
HTML
168 lines
43 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 - One Design Language</title>
|
||
<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-1.css"/>
|
||
<link rel="stylesheet" type="text/css" href="/index-2.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>');
|
||
}
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<div id="react-content">
|
||
<div class="page-wrapper" data-reactroot="" data-reactid="1" data-react-checksum="245410640"><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-6 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 style="display:block;" class="ant-col-xs-0 ant-col-sm-17 ant-col-md-18 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"><!-- react-text: 23 -->中文<!-- /react-text --></span></button><ul class="ant-menu ant-menu-horizontal ant-menu-light ant-menu-root" role="menu" aria-activedescendant="" id="nav" tabindex="0" data-reactid="24"><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="25"><a href="/" data-reactid="26"><span data-reactid="27"><!-- react-text: 28 -->Home<!-- /react-text --></span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="29"><a href="/docs/spec/introduce" data-reactid="30"><span data-reactid="31"><!-- react-text: 32 -->Specification<!-- /react-text --></span></a></li><li class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="33"><a href="/docs/react/introduce" data-reactid="34"><span data-reactid="35"><!-- react-text: 36 -->Components<!-- /react-text --></span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="37"><a href="/docs/pattern/navigation" data-reactid="38"><span data-reactid="39"><!-- react-text: 40 -->Pattern<!-- /react-text --></span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="41"><a href="/docs/practice/cases" data-reactid="42"><span data-reactid="43"><!-- react-text: 44 -->Practice<!-- /react-text --></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"><!-- react-text: 48 -->Resource<!-- /react-text --></span></a></li></ul></div></div></header><div class="main-wrapper" data-reactid="49"><div class="ant-row" data-reactid="50"><div class="ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-4" data-reactid="51"><ul class="ant-menu ant-menu-inline aside-container ant-menu-light ant-menu-root" role="menu" aria-activedescendant="" tabindex="0" data-reactid="52"><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="53"><a href="/docs/react/introduce" data-reactid="54">Ant Design of React</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="55"><a href="/docs/react/getting-started" data-reactid="56">Getting Started</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="57"><a href="/docs/react/install" data-reactid="58">Installation</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="59"><a href="/docs/react/practical-projects" data-reactid="60">Real world Example with dva</a></li><li style="padding-left:24px;" class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="61"><a href="/docs/react/use-with-create-react-app" data-reactid="62">Use with create-react-app</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="63"><a href="/docs/react/customize-theme" data-reactid="64">Customize Theme</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="65"><a href="//github.com/ant-design/intl-example" target="_blank" rel="noopener noreferrer" data-reactid="66">i18n Solution</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="67"><a href="/changelog" data-reactid="68">Change Log</a></li><li class="ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu" data-reactid="69"><div style="padding-left:24px;" class="ant-menu-submenu-title" aria-open="true" aria-owns="1482465667280_12" aria-haspopup="true" data-reactid="70"><h4 data-reactid="71">Components</h4></div><ul class="ant-menu ant-menu-inline ant-menu-sub" role="menu" aria-activedescendant="" id="1482465667280_12" data-reactid="72"><li class=" ant-menu-item-group" data-reactid="73"><div class="ant-menu-item-group-title" data-reactid="74">General</div><ul class="ant-menu-item-group-list" data-reactid="75"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="76"><a href="/components/button/" data-reactid="77"><span data-reactid="78">Button</span><span class="chinese" data-reactid="79"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="80"><a href="/components/icon/" data-reactid="81"><span data-reactid="82">Icon</span><span class="chinese" data-reactid="83"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="84"><div class="ant-menu-item-group-title" data-reactid="85">Layout</div><ul class="ant-menu-item-group-list" data-reactid="86"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="87"><a href="/components/grid/" data-reactid="88"><span data-reactid="89">Grid</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">Navigation</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/affix/" data-reactid="95"><span data-reactid="96">Affix</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/anchor/" data-reactid="99"><span data-reactid="100">Anchor</span><span class="chinese" data-reactid="101"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="102"><a href="/components/back-top/" data-reactid="103"><span data-reactid="104">BackTop</span><span class="chinese" data-reactid="105"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="106"><a href="/components/breadcrumb/" data-reactid="107"><span data-reactid="108">Breadcrumb</span><span class="chinese" data-reactid="109"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="110"><a href="/components/dropdown/" data-reactid="111"><span data-reactid="112">Dropdown</span><span class="chinese" data-reactid="113"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="114"><a href="/components/menu/" data-reactid="115"><span data-reactid="116">Menu</span><span class="chinese" data-reactid="117"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="118"><a href="/components/pagination/" data-reactid="119"><span data-reactid="120">Pagination</span><span class="chinese" data-reactid="121"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="122"><a href="/components/steps/" data-reactid="123"><span data-reactid="124">Steps</span><span class="chinese" data-reactid="125"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="126"><a href="/components/tabs/" data-reactid="127"><span data-reactid="128">Tabs</span><span class="chinese" data-reactid="129"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="130"><div class="ant-menu-item-group-title" data-reactid="131">Data Entry</div><ul class="ant-menu-item-group-list" data-reactid="132"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="133"><a href="/components/auto-complete/" data-reactid="134"><span data-reactid="135">AutoComplete</span><span class="chinese" data-reactid="136"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="137"><a href="/components/checkbox/" data-reactid="138"><span data-reactid="139">Checkbox</span><span class="chinese" data-reactid="140"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="141"><a href="/components/cascader/" data-reactid="142"><span data-reactid="143">Cascader</span><span class="chinese" data-reactid="144"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="145"><a href="/components/date-picker/" data-reactid="146"><span data-reactid="147">DatePicker</span><span class="chinese" data-reactid="148"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="149"><a href="/components/form/" data-reactid="150"><span data-reactid="151">Form</span><span class="chinese" data-reactid="152"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="153"><a href="/components/input/" data-reactid="154"><span data-reactid="155">Input</span><span class="chinese" data-reactid="156"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="157"><a href="/components/input-number/" data-reactid="158"><span data-reactid="159">InputNumber</span><span class="chinese" data-reactid="160"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="161"><a href="/components/mention/" data-reactid="162"><span data-reactid="163">Mention</span><span class="chinese" data-reactid="164"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="165"><a href="/components/radio/" data-reactid="166"><span data-reactid="167">Radio</span><span class="chinese" data-reactid="168"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="169"><a href="/components/rate/" data-reactid="170"><span data-reactid="171">Rate</span><span class="chinese" data-reactid="172"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="173"><a href="/components/select/" data-reactid="174"><span data-reactid="175">Select</span><span class="chinese" data-reactid="176"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="177"><a href="/components/slider/" data-reactid="178"><span data-reactid="179">Slider</span><span class="chinese" data-reactid="180"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="181"><a href="/components/switch/" data-reactid="182"><span data-reactid="183">Switch</span><span class="chinese" data-reactid="184"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="185"><a href="/components/time-picker/" data-reactid="186"><span data-reactid="187">TimePicker</span><span class="chinese" data-reactid="188"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="189"><a href="/components/transfer/" data-reactid="190"><span data-reactid="191">Transfer</span><span class="chinese" data-reactid="192"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="193"><a href="/components/tree-select/" data-reactid="194"><span data-reactid="195">TreeSelect</span><span class="chinese" data-reactid="196"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="197"><a href="/components/upload/" data-reactid="198"><span data-reactid="199">Upload</span><span class="chinese" data-reactid="200"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="201"><div class="ant-menu-item-group-title" data-reactid="202">Data Display</div><ul class="ant-menu-item-group-list" data-reactid="203"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="204"><a href="/components/badge/" data-reactid="205"><span data-reactid="206">Badge</span><span class="chinese" data-reactid="207"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="208"><a href="/components/card/" data-reactid="209"><span data-reactid="210">Card</span><span class="chinese" data-reactid="211"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="212"><a href="/components/carousel/" data-reactid="213"><span data-reactid="214">Carousel</span><span class="chinese" data-reactid="215"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="216"><a href="/components/collapse/" data-reactid="217"><span data-reactid="218">Collapse</span><span class="chinese" data-reactid="219"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="220"><a href="/components/calendar/" data-reactid="221"><span data-reactid="222">Calendar</span><span class="chinese" data-reactid="223"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="224"><a href="/components/popover/" data-reactid="225"><span data-reactid="226">Popover</span><span class="chinese" data-reactid="227"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="228"><a href="/components/table/" data-reactid="229"><span data-reactid="230">Table</span><span class="chinese" data-reactid="231"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="232"><a href="/components/tag/" data-reactid="233"><span data-reactid="234">Tag</span><span class="chinese" data-reactid="235"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="236"><a href="/components/timeline/" data-reactid="237"><span data-reactid="238">Timeline</span><span class="chinese" data-reactid="239"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="240"><a href="/components/tooltip/" data-reactid="241"><span data-reactid="242">Tooltip</span><span class="chinese" data-reactid="243"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="244"><a href="/components/tree/" data-reactid="245"><span data-reactid="246">Tree</span><span class="chinese" data-reactid="247"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="248"><div class="ant-menu-item-group-title" data-reactid="249">Feedback</div><ul class="ant-menu-item-group-list" data-reactid="250"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="251"><a href="/components/alert/" data-reactid="252"><span data-reactid="253">Alert</span><span class="chinese" data-reactid="254"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="255"><a href="/components/message/" data-reactid="256"><span data-reactid="257">Message</span><span class="chinese" data-reactid="258"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="259"><a href="/components/modal/" data-reactid="260"><span data-reactid="261">Modal</span><span class="chinese" data-reactid="262"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="263"><a href="/components/notification/" data-reactid="264"><span data-reactid="265">Notification</span><span class="chinese" data-reactid="266"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="267"><a href="/components/popconfirm/" data-reactid="268"><span data-reactid="269">Popconfirm</span><span class="chinese" data-reactid="270"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="271"><a href="/components/progress/" data-reactid="272"><span data-reactid="273">Progress</span><span class="chinese" data-reactid="274"></span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="275"><a href="/components/spin/" data-reactid="276"><span data-reactid="277">Spin</span><span class="chinese" data-reactid="278"></span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="279"><div class="ant-menu-item-group-title" data-reactid="280">Other</div><ul class="ant-menu-item-group-list" data-reactid="281"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="282"><a href="/components/locale-provider/" data-reactid="283"><span data-reactid="284">LocaleProvider</span><span class="chinese" data-reactid="285"></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="286"><article class="markdown" data-reactid="287"><h1 data-reactid="288"><!-- react-text: 289 -->Use with create-react-app<!-- /react-text --><a class="edit-button" href="https://github.com/ant-design/ant-design/blob/master/docs/react/use-with-create-react-app.en-US.md" data-reactid="290"><i class="anticon anticon-edit" data-reactid="291"></i></a></h1><section class="markdown" data-reactid="292"><p data-reactid="293"><a href="https://github.com/facebookincubator/create-react-app" data-reactid="294"><!-- react-text: 295 -->create-react-app<!-- /react-text --></a><!-- react-text: 296 --> is one of best React application development tool, we are going to use <!-- /react-text --><code data-reactid="297"><!-- react-text: 298 -->antd<!-- /react-text --></code><!-- react-text: 299 --> within it and modify the webpack config for some customized needs.<!-- /react-text --></p></section><section class="toc" data-reactid="300"><ul data-reactid="301"><li data-reactid="302"><a class="bisheng-toc-h2" href="#Install-and-Initialization" data-reactid="303"><!-- react-text: 304 -->Install and Initialization<!-- /react-text --></a></li><li data-reactid="305"><a class="bisheng-toc-h2" href="#Import-antd" data-reactid="306"><!-- react-text: 307 -->Import antd<!-- /react-text --></a></li><li data-reactid="308"><a class="bisheng-toc-h2" href="#Advanced-Guides" data-reactid="309"><!-- react-text: 310 -->Advanced Guides<!-- /react-text --></a></li></ul></section><section class="markdown" data-reactid="311"><h2 id="Install-and-Initialization" data-reactid="312"><span data-reactid="313"><!-- react-text: 314 -->Install and Initialization<!-- /react-text --></span><a href="#Install-and-Initialization" class="anchor" data-reactid="315">#</a></h2><p data-reactid="316"><!-- react-text: 317 -->We need to install <!-- /react-text --><code data-reactid="318"><!-- react-text: 319 -->create-react-app<!-- /react-text --></code><!-- react-text: 320 --> first.<!-- /react-text --></p><pre class="language-bash" data-reactid="321"><code data-reactid="322">$ <span class="token function">npm</span> <span class="token function">install</span> -g create-react-app</code></pre><p data-reactid="323"><!-- react-text: 324 -->Create a new project named <!-- /react-text --><code data-reactid="325"><!-- react-text: 326 -->antd-demo<!-- /react-text --></code><!-- react-text: 327 -->.<!-- /react-text --></p><pre class="language-bash" data-reactid="328"><code data-reactid="329">$ USE_YARN<span class="token operator">=</span>no create-react-app antd-demo</code></pre><p data-reactid="330"><!-- react-text: 331 -->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="332"><!-- react-text: 333 -->Then we go inside <!-- /react-text --><code data-reactid="334"><!-- react-text: 335 -->antd-demo<!-- /react-text --></code><!-- react-text: 336 --> and start it.<!-- /react-text --></p><pre class="language-bash" data-reactid="337"><code data-reactid="338">$ <span class="token function">cd</span> antd-demo
|
||
$ <span class="token function">npm</span> start</code></pre><p data-reactid="339"><!-- react-text: 340 -->Open browser at <!-- /react-text --><a href="http://localhost:3000/" data-reactid="341"><!-- react-text: 342 -->http://localhost:3000/<!-- /react-text --></a><!-- react-text: 343 -->, it renders a header saying "Welcome to React" on the page.<!-- /react-text --></p><h2 id="Import-antd" data-reactid="344"><span data-reactid="345"><!-- react-text: 346 -->Import antd<!-- /react-text --></span><a href="#Import-antd" class="anchor" data-reactid="347">#</a></h2><p data-reactid="348"><!-- react-text: 349 -->It is the default directory structure below.<!-- /react-text --></p><pre class="language-null" data-reactid="350"><code data-reactid="351">├── 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="352"><!-- react-text: 353 -->Now we install <!-- /react-text --><code data-reactid="354"><!-- react-text: 355 -->antd<!-- /react-text --></code><!-- react-text: 356 --> from npm.<!-- /react-text --></p><pre class="language-bash" data-reactid="357"><code data-reactid="358">$ <span class="token function">npm</span> <span class="token function">install</span> antd --save</code></pre><p data-reactid="359"><!-- react-text: 360 -->Modify <!-- /react-text --><code data-reactid="361"><!-- react-text: 362 -->src/App.js<!-- /react-text --></code><!-- react-text: 363 -->, import Button component from <!-- /react-text --><code data-reactid="364"><!-- react-text: 365 -->antd<!-- /react-text --></code><!-- react-text: 366 -->.<!-- /react-text --></p><pre class="language-jsx" data-reactid="367"><code data-reactid="368"><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="369"><!-- react-text: 370 -->Add <!-- /react-text --><code data-reactid="371"><!-- react-text: 372 -->antd/dist/antd.css<!-- /react-text --></code><!-- react-text: 373 --> at the top of <!-- /react-text --><code data-reactid="374"><!-- react-text: 375 -->src/App.css<!-- /react-text --></code><!-- react-text: 376 -->.<!-- /react-text --></p><pre class="language-css" data-reactid="377"><code data-reactid="378"><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="379"><!-- react-text: 380 -->Ok, you now see a blue primary button displaying in page now, next you can choose any components of <!-- /react-text --><code data-reactid="381"><!-- react-text: 382 -->antd<!-- /react-text --></code><!-- react-text: 383 --> to develop your application. Visit other workflow of <!-- /react-text --><code data-reactid="384"><!-- react-text: 385 -->create-react-app<!-- /react-text --></code><!-- react-text: 386 --> at its <!-- /react-text --><a href="https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md" data-reactid="387"><!-- react-text: 388 -->User Guide <!-- /react-text --></a><!-- react-text: 389 -->.<!-- /react-text --></p><h2 id="Advanced-Guides" data-reactid="390"><span data-reactid="391"><!-- react-text: 392 -->Advanced Guides<!-- /react-text --></span><a href="#Advanced-Guides" class="anchor" data-reactid="393">#</a></h2><p data-reactid="394"><!-- react-text: 395 -->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="396"><p data-reactid="397"><!-- react-text: 398 -->You will see a warning in your browser console.<!-- /react-text --></p></blockquote><p data-reactid="399"><img src="https://zos.alipayobjects.com/rmsportal/dBLScZPjiUwunfyQVISX.png" data-reactid="400"/></p><p data-reactid="401"><!-- react-text: 402 -->So it is necessary to customize the default webpack config. We can achieve that by using <!-- /react-text --><code data-reactid="403"><!-- react-text: 404 -->eject<!-- /react-text --></code><!-- react-text: 405 --> script command.<!-- /react-text --></p><pre class="language-bash" data-reactid="406"><code data-reactid="407">$ <span class="token function">npm</span> run <span class="token function">eject</span></code></pre><h3 id="Import-on-demand" data-reactid="408"><span data-reactid="409"><!-- react-text: 410 -->Import on demand<!-- /react-text --></span><a href="#Import-on-demand" class="anchor" data-reactid="411">#</a></h3><p data-reactid="412"><!-- react-text: 413 -->After eject all config files to antd-demo, we allowed to install <!-- /react-text --><a href="https://github.com/ant-design/babel-plugin-import" data-reactid="414"><!-- react-text: 415 -->babel-plugin-import<!-- /react-text --></a><!-- react-text: 416 --> and modify <!-- /react-text --><code data-reactid="417"><!-- react-text: 418 -->src/webconfig.dev.js<!-- /react-text --></code><!-- react-text: 419 --> now.<!-- /react-text --></p><pre class="language-bash" data-reactid="420"><code data-reactid="421">$ <span class="token function">npm</span> <span class="token function">install</span> babel-plugin-import --save-dev</code></pre><pre class="language-diff" data-reactid="422"><code data-reactid="423">// 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><p data-reactid="424"><!-- react-text: 425 -->Remove the <!-- /react-text --><code data-reactid="426"><!-- react-text: 427 -->@import '~antd/dist/antd.css';<!-- /react-text --></code><!-- react-text: 428 --> statement added before because <!-- /react-text --><code data-reactid="429"><!-- react-text: 430 -->babel-plugin-import<!-- /react-text --></code><!-- react-text: 431 --> will import styles.<!-- /react-text --></p><p data-reactid="432"><!-- react-text: 433 -->Then reboot <!-- /react-text --><code data-reactid="434"><!-- react-text: 435 -->npm start<!-- /react-text --></code><!-- react-text: 436 --> and visit demo page, you should find that the above warning message would be gone which prove the <!-- /react-text --><code data-reactid="437"><!-- react-text: 438 -->import on demand<!-- /react-text --></code><!-- react-text: 439 --> config is effective now.<!-- /react-text --></p><h3 id="Customize-Theme" data-reactid="440"><span data-reactid="441"><!-- react-text: 442 -->Customize Theme<!-- /react-text --></span><a href="#Customize-Theme" class="anchor" data-reactid="443">#</a></h3><p data-reactid="444"><!-- react-text: 445 -->According to <!-- /react-text --><a href="/docs/react/customize-theme" data-reactid="446">Customize Theme documentation</a><!-- react-text: 447 -->, we need <!-- /react-text --><code data-reactid="448"><!-- react-text: 449 -->less<!-- /react-text --></code><!-- react-text: 450 --> variables modify ability of <!-- /react-text --><a href="https://github.com/webpack/less-loader" data-reactid="451"><!-- react-text: 452 -->less-loader<!-- /react-text --></a><!-- react-text: 453 -->, so we add it.<!-- /react-text --></p><pre class="language-bash" data-reactid="454"><code data-reactid="455">$ <span class="token function">npm</span> <span class="token function">install</span> <span class="token function">less</span> less-loader --save-dev</code></pre><pre class="language-diff" data-reactid="456"><code data-reactid="457">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="458"><!-- react-text: 459 -->We use <!-- /react-text --><code data-reactid="460"><!-- react-text: 461 -->modifyVars<!-- /react-text --></code><!-- react-text: 462 --> option of <!-- /react-text --><a href="https://github.com/webpack/less-loader#less-options" data-reactid="463"><!-- react-text: 464 -->less-loader<!-- /react-text --></a><!-- react-text: 465 --> here, you can see a green button rendered on the page after reboot start server.<!-- /react-text --></p><hr data-reactid="466"/><p data-reactid="467"><!-- react-text: 468 -->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="469"><!-- react-text: 470 -->atool-build<!-- /react-text --></a><!-- react-text: 471 -->.<!-- /react-text --></p><p data-reactid="472"><!-- react-text: 473 -->Source code about this article:<!-- /react-text --><a href="https://github.com/ant-design/create-react-app-antd" data-reactid="474"><!-- react-text: 475 -->https://github.com/ant-design/create-react-app-antd<!-- /react-text --></a></p></section></article></div></div><div class="ant-row" data-reactid="476"><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="477"><section class="prev-next-nav" data-reactid="478"><a class="prev-page" href="/docs/react/practical-projects" data-reactid="479">Real world Example with dva</a><a class="next-page" href="/docs/react/customize-theme" data-reactid="480">Customize Theme</a></section></div></div></div><footer id="footer" data-reactid="481"><ul data-reactid="482"><li data-reactid="483"><h2 data-reactid="484">GitHub</h2><div data-reactid="485"><a target="_blank " href="https://github.com/ant-design/ant-design" data-reactid="486"><span data-reactid="487"><!-- react-text: 488 -->Repository<!-- /react-text --></span></a></div><div data-reactid="489"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva" data-reactid="490">dva</a><!-- react-text: 491 --> - <!-- /react-text --><span data-reactid="492"><!-- react-text: 493 -->Framework<!-- /react-text --></span></div><div data-reactid="494"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva-cli" data-reactid="495">dva-cli</a><!-- react-text: 496 --> -<!-- /react-text --><span data-reactid="497"><!-- react-text: 498 -->Scaffold<!-- /react-text --></span></div><div data-reactid="499"><a target="_blank" rel="noopener noreferrer" href="http://ant-tool.github.io" data-reactid="500">ant-tool</a><!-- react-text: 501 --> - <!-- /react-text --><span data-reactid="502"><!-- react-text: 503 -->Developer Tools<!-- /react-text --></span></div></li><li data-reactid="504"><h2 data-reactid="505"><span data-reactid="506"><!-- react-text: 507 -->Links<!-- /react-text --></span></h2><div data-reactid="508"><a href="http://mobile.ant.design" data-reactid="509">Ant Design Mobile</a><span data-reactid="510"> - </span><span data-reactid="511"><!-- react-text: 512 -->Mobile<!-- /react-text --></span></div><div data-reactid="513"><a href="https://g2.alipay.com/" data-reactid="514">G2</a><span data-reactid="515"> - </span><span data-reactid="516"><!-- react-text: 517 -->Data Visualization<!-- /react-text --></span></div><div data-reactid="518"><a href="https://antv.alipay.com/" data-reactid="519">AntV</a><span data-reactid="520"> - </span><span data-reactid="521"><!-- react-text: 522 -->Data Visualization Specification<!-- /react-text --></span></div><div data-reactid="523"><a href="http://motion.ant.design" data-reactid="524">Ant Motion</a><span data-reactid="525"> - </span><span data-reactid="526"><!-- react-text: 527 -->Motion<!-- /react-text --></span></div><div data-reactid="528"><a href="http://library.ant.design/" data-reactid="529">AntD Library</a><span data-reactid="530"> - </span><span data-reactid="531"><!-- react-text: 532 -->Axure library of Ant Design<!-- /react-text --></span></div><div data-reactid="533"><a href="http://ux.ant.design" data-reactid="534">Ant UX</a><span data-reactid="535"> - </span><span data-reactid="536"><!-- react-text: 537 -->Sitemap Template<!-- /react-text --></span></div></li><li data-reactid="538"><h2 data-reactid="539"><span data-reactid="540"><!-- react-text: 541 -->Community<!-- /react-text --></span></h2><div data-reactid="542"><a rel="noopener noreferrer" href="/changelog" data-reactid="543"><span data-reactid="544"><!-- react-text: 545 -->Change Log<!-- /react-text --></span></a></div><div data-reactid="546"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/issues" data-reactid="547"><span data-reactid="548"><!-- react-text: 549 -->Feedback<!-- /react-text --></span></a></div><div data-reactid="550"><a target="_blank" rel="noopener noreferrer" href="https://gitter.im/ant-design/ant-design" data-reactid="551"><span data-reactid="552"><!-- react-text: 553 -->Chat Room<!-- /react-text --></span></a></div><div data-reactid="554"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/issues/new" data-reactid="555"><span data-reactid="556"><!-- react-text: 557 -->Bug Report<!-- /react-text --></span></a></div></li><li data-reactid="558"><div data-reactid="559"><!-- react-text: 560 -->©2016 <!-- /react-text --><span data-reactid="561"><!-- react-text: 562 -->Created by Ant UED<!-- /react-text --></span></div><div data-reactid="563"><!-- react-text: 564 -->Powered by <!-- /react-text --><a href="https://github.com/benjycui/bisheng" data-reactid="565">BiSheng</a></div><div style="margin-top:10px;" data-reactid="566"><span data-reactid="567"><!-- react-text: 568 -->Version: <!-- /react-text --></span><div class="ant-select-sm ant-select ant-select-enabled" data-reactid="569"><div class="ant-select-selection
|
||
ant-select-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" tabindex="0" data-reactid="570"><div class="ant-select-selection__rendered" data-reactid="571"><div class="ant-select-selection-selected-value" title="1.11.4" style="display:block;opacity:1;" data-reactid="572">1.11.4</div></div><span class="ant-select-arrow" style="user-select:none;-webkit-user-select:none;" unselectable="unselectable" data-reactid="573"><b data-reactid="574"></b></span></div></div></div></li></ul></footer></div>
|
||
</div>
|
||
<script>
|
||
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';
|
||
}
|
||
var queryString = location.search;
|
||
if (queryString) {
|
||
var pathname = location.pathname;
|
||
var isZhCNConfig = queryString.indexOf('zh-CN') > -1;
|
||
if (isZhCNConfig !== isZhCN(pathname)) {
|
||
location.pathname = getLocalizedPathname(pathname, isZhCNConfig)
|
||
}
|
||
}
|
||
</script>
|
||
<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>
|
||
<script src="/common.js"></script>
|
||
<script src="/index.js"></script>
|
||
</body>
|
||
</html>
|