mirror of
https://github.com/wahyd4/ant-design.git
synced 2026-08-18 09:16:50 +10:00
172 lines
55 KiB
HTML
172 lines
55 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="Ant Design - An enterprise-class UI design language and React-based implementation">
|
||
<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"/>
|
||
<!--[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="-924432566"><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="/index-cn" 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">搜索组件...</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">EN</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="23"><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="24"><a href="/index-cn" data-reactid="25"><span data-reactid="26">首页</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="27"><a href="/docs/spec/introduce-cn" data-reactid="28"><span data-reactid="29">规范</span></a></li><li class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="30"><a href="/docs/react/introduce-cn" data-reactid="31"><span data-reactid="32">组件</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="33"><a href="/docs/pattern/navigation-cn" data-reactid="34"><span data-reactid="35">模式</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="36"><a href="/docs/practice/cases-cn" data-reactid="37"><span data-reactid="38">实践</span></a></li><li class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="39"><a href="/docs/resource/download-cn" data-reactid="40"><span data-reactid="41">资源</span></a></li></ul></div></div></header><div class="main-wrapper" data-reactid="42"><div class="ant-row" data-reactid="43"><div class="ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-4" data-reactid="44"><ul class="ant-menu ant-menu-inline aside-container ant-menu-light ant-menu-root" role="menu" aria-activedescendant="" tabindex="0" data-reactid="45"><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="46"><a href="/docs/react/introduce-cn" data-reactid="47">Ant Design of React</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="48"><a href="/docs/react/getting-started-cn" data-reactid="49">快速上手</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="50"><a href="/docs/react/install-cn" data-reactid="51">安装</a></li><li style="padding-left:24px;" class="ant-menu-item-selected ant-menu-item" role="menuitem" aria-selected="true" data-reactid="52"><a href="/docs/react/practical-projects-cn" data-reactid="53">项目实战</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="54"><a href="/docs/react/customize-theme-cn" data-reactid="55">定制主题</a></li><li style="padding-left:24px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="56"><a href="/changelog-cn" data-reactid="57">更新日志</a></li><li class="ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu" data-reactid="58"><div style="padding-left:24px;" class="ant-menu-submenu-title" aria-open="true" aria-owns="1480927040652_9" aria-haspopup="true" data-reactid="59"><h4 data-reactid="60">Components</h4></div><ul class="ant-menu ant-menu-inline ant-menu-sub" role="menu" aria-activedescendant="" id="1480927040652_9" data-reactid="61"><li class=" ant-menu-item-group" data-reactid="62"><div class="ant-menu-item-group-title" data-reactid="63">General</div><ul class="ant-menu-item-group-list" data-reactid="64"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="65"><a href="/components/button-cn/" data-reactid="66"><span data-reactid="67">Button</span><span class="chinese" data-reactid="68">按钮</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="69"><a href="/components/icon-cn/" data-reactid="70"><span data-reactid="71">Icon</span><span class="chinese" data-reactid="72">图标</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="73"><div class="ant-menu-item-group-title" data-reactid="74">Layout</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/grid-cn/" data-reactid="77"><span data-reactid="78">Grid</span><span class="chinese" data-reactid="79">栅格</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="80"><div class="ant-menu-item-group-title" data-reactid="81">Navigation</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/affix-cn/" data-reactid="84"><span data-reactid="85">Affix</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/anchor-cn/" data-reactid="88"><span data-reactid="89">Anchor</span><span class="chinese" data-reactid="90">锚点</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="91"><a href="/components/back-top-cn/" data-reactid="92"><span data-reactid="93">BackTop</span><span class="chinese" data-reactid="94">回到顶部</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="95"><a href="/components/breadcrumb-cn/" data-reactid="96"><span data-reactid="97">Breadcrumb</span><span class="chinese" data-reactid="98">面包屑</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="99"><a href="/components/dropdown-cn/" data-reactid="100"><span data-reactid="101">Dropdown</span><span class="chinese" data-reactid="102">下拉菜单</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="103"><a href="/components/menu-cn/" data-reactid="104"><span data-reactid="105">Menu</span><span class="chinese" data-reactid="106">导航菜单</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="107"><a href="/components/pagination-cn/" data-reactid="108"><span data-reactid="109">Pagination</span><span class="chinese" data-reactid="110">分页</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="111"><a href="/components/steps-cn/" data-reactid="112"><span data-reactid="113">Steps</span><span class="chinese" data-reactid="114">步骤条</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="115"><a href="/components/tabs-cn/" data-reactid="116"><span data-reactid="117">Tabs</span><span class="chinese" data-reactid="118">标签页</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="119"><div class="ant-menu-item-group-title" data-reactid="120">Data Entry</div><ul class="ant-menu-item-group-list" data-reactid="121"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="122"><a href="/components/auto-complete-cn/" data-reactid="123"><span data-reactid="124">AutoComplete</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/checkbox-cn/" data-reactid="127"><span data-reactid="128">Checkbox</span><span class="chinese" data-reactid="129">多选框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="130"><a href="/components/cascader-cn/" data-reactid="131"><span data-reactid="132">Cascader</span><span class="chinese" data-reactid="133">级联选择</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="134"><a href="/components/date-picker-cn/" data-reactid="135"><span data-reactid="136">DatePicker</span><span class="chinese" data-reactid="137">日期选择框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="138"><a href="/components/form-cn/" data-reactid="139"><span data-reactid="140">Form</span><span class="chinese" data-reactid="141">表单</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="142"><a href="/components/input-cn/" data-reactid="143"><span data-reactid="144">Input</span><span class="chinese" data-reactid="145">输入框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="146"><a href="/components/input-number-cn/" data-reactid="147"><span data-reactid="148">InputNumber</span><span class="chinese" data-reactid="149">数字输入框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="150"><a href="/components/mention-cn/" data-reactid="151"><span data-reactid="152">Mention</span><span class="chinese" data-reactid="153">提及</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="154"><a href="/components/radio-cn/" data-reactid="155"><span data-reactid="156">Radio</span><span class="chinese" data-reactid="157">单选框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="158"><a href="/components/rate-cn/" data-reactid="159"><span data-reactid="160">Rate</span><span class="chinese" data-reactid="161">评分</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="162"><a href="/components/select-cn/" data-reactid="163"><span data-reactid="164">Select</span><span class="chinese" data-reactid="165">选择器</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="166"><a href="/components/slider-cn/" data-reactid="167"><span data-reactid="168">Slider</span><span class="chinese" data-reactid="169">滑动输入条</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="170"><a href="/components/switch-cn/" data-reactid="171"><span data-reactid="172">Switch</span><span class="chinese" data-reactid="173">开关</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="174"><a href="/components/time-picker-cn/" data-reactid="175"><span data-reactid="176">TimePicker</span><span class="chinese" data-reactid="177">时间选择框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="178"><a href="/components/transfer-cn/" data-reactid="179"><span data-reactid="180">Transfer</span><span class="chinese" data-reactid="181">穿梭框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="182"><a href="/components/tree-select-cn/" data-reactid="183"><span data-reactid="184">TreeSelect</span><span class="chinese" data-reactid="185">树选择</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="186"><a href="/components/upload-cn/" data-reactid="187"><span data-reactid="188">Upload</span><span class="chinese" data-reactid="189">上传</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="190"><div class="ant-menu-item-group-title" data-reactid="191">Data Display</div><ul class="ant-menu-item-group-list" data-reactid="192"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="193"><a href="/components/badge-cn/" data-reactid="194"><span data-reactid="195">Badge</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/card-cn/" data-reactid="198"><span data-reactid="199">Card</span><span class="chinese" data-reactid="200">卡片</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="201"><a href="/components/carousel-cn/" data-reactid="202"><span data-reactid="203">Carousel</span><span class="chinese" data-reactid="204">走马灯</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="205"><a href="/components/collapse-cn/" data-reactid="206"><span data-reactid="207">Collapse</span><span class="chinese" data-reactid="208">折叠面板</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="209"><a href="/components/calendar-cn/" data-reactid="210"><span data-reactid="211">Calendar</span><span class="chinese" data-reactid="212">日历</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="213"><a href="/components/popover-cn/" data-reactid="214"><span data-reactid="215">Popover</span><span class="chinese" data-reactid="216">气泡卡片</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="217"><a href="/components/table-cn/" data-reactid="218"><span data-reactid="219">Table</span><span class="chinese" data-reactid="220">表格</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="221"><a href="/components/tag-cn/" data-reactid="222"><span data-reactid="223">Tag</span><span class="chinese" data-reactid="224">标签</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="225"><a href="/components/timeline-cn/" data-reactid="226"><span data-reactid="227">Timeline</span><span class="chinese" data-reactid="228">时间轴</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="229"><a href="/components/tooltip-cn/" data-reactid="230"><span data-reactid="231">Tooltip</span><span class="chinese" data-reactid="232">文字提示</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="233"><a href="/components/tree-cn/" data-reactid="234"><span data-reactid="235">Tree</span><span class="chinese" data-reactid="236">树形控件</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="237"><div class="ant-menu-item-group-title" data-reactid="238">Feedback</div><ul class="ant-menu-item-group-list" data-reactid="239"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="240"><a href="/components/alert-cn/" data-reactid="241"><span data-reactid="242">Alert</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/message-cn/" data-reactid="245"><span data-reactid="246">Message</span><span class="chinese" data-reactid="247">全局提示</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="248"><a href="/components/modal-cn/" data-reactid="249"><span data-reactid="250">Modal</span><span class="chinese" data-reactid="251">对话框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="252"><a href="/components/notification-cn/" data-reactid="253"><span data-reactid="254">Notification</span><span class="chinese" data-reactid="255">通知提醒框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="256"><a href="/components/popconfirm-cn/" data-reactid="257"><span data-reactid="258">Popconfirm</span><span class="chinese" data-reactid="259">气泡确认框</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="260"><a href="/components/progress-cn/" data-reactid="261"><span data-reactid="262">Progress</span><span class="chinese" data-reactid="263">进度条</span></a></li><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="264"><a href="/components/spin-cn/" data-reactid="265"><span data-reactid="266">Spin</span><span class="chinese" data-reactid="267">加载中</span></a></li></ul></li><li class=" ant-menu-item-group" data-reactid="268"><div class="ant-menu-item-group-title" data-reactid="269">Other</div><ul class="ant-menu-item-group-list" data-reactid="270"><li style="padding-left:48px;" class="ant-menu-item" role="menuitem" aria-selected="false" data-reactid="271"><a href="/components/locale-provider-cn/" data-reactid="272"><span data-reactid="273">LocaleProvider</span><span class="chinese" data-reactid="274">国际化</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="275"><article class="markdown" data-reactid="276"><h1 data-reactid="277"><!-- react-text: 278 -->项目实战<!-- /react-text --><a class="edit-button" href="https://github.com/ant-design/ant-design/blob/master/docs/react/practical-projects.zh-CN.md" data-reactid="279"><i class="anticon anticon-edit" data-reactid="280"></i></a></h1><section class="markdown" data-reactid="281"><p data-reactid="282"><a href="https://github.com/dvajs/dva" data-reactid="283"><!-- react-text: 284 -->dva<!-- /react-text --></a><!-- react-text: 285 --> 是一个基于 react 和 redux 的轻量应用框架,概念来自 elm,支持 side effects、热替换、动态加载、react-native、SSR 等,已在生产环境广泛应用。<!-- /react-text --></p><p data-reactid="286"><!-- react-text: 287 -->本文会引导你使用 dva 和 antd 从 0 开始创建一个简单应用。<!-- /react-text --></p><p data-reactid="288"><!-- react-text: 289 -->会包含以下内容:<!-- /react-text --></p></section><section class="toc" data-reactid="290"><ul data-reactid="291"><li data-reactid="292"><a href="#安装-dva" data-reactid="293"><!-- react-text: 294 -->安装 dva<!-- /react-text --></a></li><li data-reactid="295"><a href="#创建新应用" data-reactid="296"><!-- react-text: 297 -->创建新应用<!-- /react-text --></a></li><li data-reactid="298"><a href="#使用-antd" data-reactid="299"><!-- react-text: 300 -->使用 antd<!-- /react-text --></a></li><li data-reactid="301"><a href="#定义路由" data-reactid="302"><!-- react-text: 303 -->定义路由<!-- /react-text --></a></li><li data-reactid="304"><a href="#编写-UI-Component" data-reactid="305"><!-- react-text: 306 -->编写 UI Component<!-- /react-text --></a></li><li data-reactid="307"><a href="#定义-Model" data-reactid="308"><!-- react-text: 309 -->定义 Model<!-- /react-text --></a></li><li data-reactid="310"><a href="#connect-起来" data-reactid="311"><!-- react-text: 312 -->connect 起来<!-- /react-text --></a></li><li data-reactid="313"><a href="#构建应用" data-reactid="314"><!-- react-text: 315 -->构建应用<!-- /react-text --></a></li><li data-reactid="316"><a href="#下一步" data-reactid="317"><!-- react-text: 318 -->下一步<!-- /react-text --></a></li></ul></section><section class="markdown" data-reactid="319"><h2 id="安装-dva" data-reactid="320"><span data-reactid="321"><!-- react-text: 322 -->安装 dva<!-- /react-text --></span><a href="#安装-dva" class="anchor" data-reactid="323">#</a></h2><p data-reactid="324"><!-- react-text: 325 -->通过 npm 安装 dva 。<!-- /react-text --></p><pre class="language-bash" data-reactid="326"><code data-reactid="327">$ npm <span class="token function" >install</span> dva-cli -g</code></pre><h2 id="创建新应用" data-reactid="328"><span data-reactid="329"><!-- react-text: 330 -->创建新应用<!-- /react-text --></span><a href="#创建新应用" class="anchor" data-reactid="331">#</a></h2><p data-reactid="332"><!-- react-text: 333 -->安装完 dva-cli 之后,就可以在 terminal 里访问到 <!-- /react-text --><code data-reactid="334"><!-- react-text: 335 -->dva<!-- /react-text --></code><!-- react-text: 336 --> 命令。现在,你可以通过 <!-- /react-text --><code data-reactid="337"><!-- react-text: 338 -->dva new<!-- /react-text --></code><!-- react-text: 339 --> 创建新应用。<!-- /react-text --></p><pre class="language-bash" data-reactid="340"><code data-reactid="341">$ dva new dva-quickstart</code></pre><p data-reactid="342"><!-- react-text: 343 -->这会创建 <!-- /react-text --><code data-reactid="344"><!-- react-text: 345 -->dva-quickstart<!-- /react-text --></code><!-- react-text: 346 --> 目录,包含项目初始化目录和文件,并提供开发服务器、构建脚本、数据 mock 服务、代理服务器等功能。<!-- /react-text --></p><p data-reactid="347"><!-- react-text: 348 -->然后我们 <!-- /react-text --><code data-reactid="349"><!-- react-text: 350 -->cd<!-- /react-text --></code><!-- react-text: 351 --> 进入 <!-- /react-text --><code data-reactid="352"><!-- react-text: 353 -->dva-quickstart<!-- /react-text --></code><!-- react-text: 354 --> 目录,并启动开发服务器:<!-- /react-text --></p><pre class="language-bash" data-reactid="355"><code data-reactid="356">$ <span class="token function" >cd</span> dva-quickstart
|
||
$ npm start</code></pre><p data-reactid="357"><!-- react-text: 358 -->几秒钟后,你会看到以下输出:<!-- /react-text --></p><pre class="language-bash" data-reactid="359"><code data-reactid="360"> proxy: load rule from proxy.config.js
|
||
proxy: listened on 8989
|
||
📦 411/411 build modules
|
||
webpack: bundle build is now finished.</code></pre><p data-reactid="361"><!-- react-text: 362 -->在浏览器里打开 <!-- /react-text --><a href="http://localhost:8989" data-reactid="363"><!-- react-text: 364 -->http://localhost:8989<!-- /react-text --></a><!-- react-text: 365 --> ,你会看到 dva 的欢迎界面。<!-- /react-text --></p><h2 id="使用-antd" data-reactid="366"><span data-reactid="367"><!-- react-text: 368 -->使用 antd<!-- /react-text --></span><a href="#使用-antd" class="anchor" data-reactid="369">#</a></h2><p data-reactid="370"><!-- react-text: 371 -->通过 npm 安装 <!-- /react-text --><code data-reactid="372"><!-- react-text: 373 -->antd<!-- /react-text --></code><!-- react-text: 374 --> 和 <!-- /react-text --><code data-reactid="375"><!-- react-text: 376 -->babel-plugin-import<!-- /react-text --></code><!-- react-text: 377 --> 。<!-- /react-text --><code data-reactid="378"><!-- react-text: 379 -->babel-plugin-import<!-- /react-text --></code><!-- react-text: 380 --> 是用来按需加载 antd 的脚本和样式的,详见 <!-- /react-text --><a href="https://github.com/ant-design/babel-plugin-import" data-reactid="381"><!-- react-text: 382 -->repo<!-- /react-text --></a><!-- react-text: 383 --> 。<!-- /react-text --></p><pre class="language-bash" data-reactid="384"><code data-reactid="385">$ npm <span class="token function" >install</span> antd babel-plugin-import --save</code></pre><p data-reactid="386"><!-- react-text: 387 -->编辑 <!-- /react-text --><code data-reactid="388"><!-- react-text: 389 -->webpack.config.js<!-- /react-text --></code><!-- react-text: 390 -->,使 <!-- /react-text --><code data-reactid="391"><!-- react-text: 392 -->babel-plugin-import<!-- /react-text --></code><!-- react-text: 393 --> 插件生效。<!-- /react-text --></p><pre class="language-diff" data-reactid="394"><code data-reactid="395"><span class="token inserted" >+ webpackConfig.babel.plugins.push(['import', {</span>
|
||
<span class="token inserted" >+ libraryName: 'antd',</span>
|
||
<span class="token inserted" >+ style: 'css',</span>
|
||
<span class="token inserted" >+ }]);</span></code></pre><blockquote data-reactid="396"><p data-reactid="397"><!-- react-text: 398 -->注:这里不需要手动重启开发服务器,保存 <!-- /react-text --><code data-reactid="399"><!-- react-text: 400 -->webpack.config.js<!-- /react-text --></code><!-- react-text: 401 --> 后会自动重启。<!-- /react-text --></p></blockquote><h2 id="定义路由" data-reactid="402"><span data-reactid="403"><!-- react-text: 404 -->定义路由<!-- /react-text --></span><a href="#定义路由" class="anchor" data-reactid="405">#</a></h2><p data-reactid="406"><!-- react-text: 407 -->我们要写个应用来先显示产品列表。首先第一步是创建路由,路由可以想象成是组成应用的不同页面。<!-- /react-text --></p><p data-reactid="408"><!-- react-text: 409 -->新建 route component <!-- /react-text --><code data-reactid="410"><!-- react-text: 411 -->routes/Products.js<!-- /react-text --></code><!-- react-text: 412 -->,内容如下:<!-- /react-text --></p><pre class="language-javascript" data-reactid="413"><code data-reactid="414"><span class="token keyword" >import</span> React <span class="token keyword" >from</span> <span class="token string" >'react'</span><span class="token punctuation" >;</span>
|
||
|
||
<span class="token keyword" >const</span> Products <span class="token operator" >=</span> <span class="token punctuation" >(</span>props<span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation" >(</span>
|
||
<span class="token operator" ><</span>h2<span class="token operator" >></span>List <span class="token keyword" >of</span> Products<span class="token operator" ><</span><span class="token operator" >/</span>h2<span class="token operator" >></span>
|
||
<span class="token punctuation" >)</span><span class="token punctuation" >;</span>
|
||
|
||
<span class="token keyword" >export</span> <span class="token keyword" >default</span> Products<span class="token punctuation" >;</span></code></pre><p data-reactid="415"><!-- react-text: 416 -->添加路由信息到路由表,编辑 <!-- /react-text --><code data-reactid="417"><!-- react-text: 418 -->router.js<!-- /react-text --></code><!-- react-text: 419 --> :<!-- /react-text --></p><pre class="language-diff" data-reactid="420"><code data-reactid="421"><span class="token inserted" >+ import Products from './routes/Products';</span>
|
||
...
|
||
<span class="token inserted" >+ <Route path="/products" component={Products} /></span></code></pre><p data-reactid="422"><!-- react-text: 423 -->然后在浏览器里打开 <!-- /react-text --><a href="http://localhost:8989/#/products" data-reactid="424"><!-- react-text: 425 -->http://localhost:8989/#/products<!-- /react-text --></a><!-- react-text: 426 --> ,你应该能看到前面定义的 <!-- /react-text --><code data-reactid="427"><!-- react-text: 428 --><h2><!-- /react-text --></code><!-- react-text: 429 --> 标签。<!-- /react-text --></p><h2 id="编写-UI-Component" data-reactid="430"><span data-reactid="431"><!-- react-text: 432 -->编写 UI Component<!-- /react-text --></span><a href="#编写-UI-Component" class="anchor" data-reactid="433">#</a></h2><p data-reactid="434"><!-- react-text: 435 -->随着应用的发展,你会需要在多个页面分享 UI 元素 (或在一个页面使用多次),在 dva 里你可以把这部分抽成 component 。<!-- /react-text --></p><p data-reactid="436"><!-- react-text: 437 -->我们来编写一个 <!-- /react-text --><code data-reactid="438"><!-- react-text: 439 -->ProductList<!-- /react-text --></code><!-- react-text: 440 --> component,这样就能在不同的地方显示产品列表了。<!-- /react-text --></p><p data-reactid="441"><!-- react-text: 442 -->新建 <!-- /react-text --><code data-reactid="443"><!-- react-text: 444 -->components/ProductList.js<!-- /react-text --></code><!-- react-text: 445 --> 文件:<!-- /react-text --></p><pre class="language-javascript" data-reactid="446"><code data-reactid="447"><span class="token keyword" >import</span> React<span class="token punctuation" >,</span> <span class="token punctuation" >{</span> PropTypes <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> Table<span class="token punctuation" >,</span> Popconfirm<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" >const</span> ProductList <span class="token operator" >=</span> <span class="token punctuation" >(</span><span class="token punctuation" >{</span> onDelete<span class="token punctuation" >,</span> products <span class="token punctuation" >}</span><span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation" >{</span>
|
||
<span class="token keyword" >const</span> columns <span class="token operator" >=</span> <span class="token punctuation" >[</span><span class="token punctuation" >{</span>
|
||
title<span class="token punctuation" >:</span> <span class="token string" >'Name'</span><span class="token punctuation" >,</span>
|
||
dataIndex<span class="token punctuation" >:</span> <span class="token string" >'name'</span><span class="token punctuation" >,</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >,</span> <span class="token punctuation" >{</span>
|
||
title<span class="token punctuation" >:</span> <span class="token string" >'Actions'</span><span class="token punctuation" >,</span>
|
||
render<span class="token punctuation" >:</span> <span class="token punctuation" >(</span>text<span class="token punctuation" >,</span> record<span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation" >{</span>
|
||
<span class="token keyword" >return</span> <span class="token punctuation" >(</span>
|
||
<span class="token operator" ><</span>Popconfirm title<span class="token operator" >=</span><span class="token string" >"Delete?"</span> onConfirm<span class="token operator" >=</span><span class="token punctuation" >{</span><span class="token punctuation" >(</span><span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token function" >onDelete</span><span class="token punctuation" >(</span>record<span class="token punctuation" >.</span>id<span class="token punctuation" >)</span><span class="token punctuation" >}</span><span class="token operator" >></span>
|
||
<span class="token operator" ><</span>Button<span class="token operator" >></span>Delete<span class="token operator" ><</span><span class="token operator" >/</span>Button<span class="token operator" >></span>
|
||
<span class="token operator" ><</span><span class="token operator" >/</span>Popconfirm<span class="token operator" >></span>
|
||
<span class="token punctuation" >)</span><span class="token punctuation" >;</span>
|
||
<span class="token punctuation" >}</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" >return</span> <span class="token punctuation" >(</span>
|
||
<span class="token operator" ><</span>Table
|
||
dataSource<span class="token operator" >=</span><span class="token punctuation" >{</span>products<span class="token punctuation" >}</span>
|
||
columns<span class="token operator" >=</span><span class="token punctuation" >{</span>columns<span class="token punctuation" >}</span>
|
||
<span class="token operator" >/</span><span class="token operator" >></span>
|
||
<span class="token punctuation" >)</span><span class="token punctuation" >;</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >;</span>
|
||
|
||
ProductList<span class="token punctuation" >.</span>propTypes <span class="token operator" >=</span> <span class="token punctuation" >{</span>
|
||
onDelete<span class="token punctuation" >:</span> PropTypes<span class="token punctuation" >.</span>func<span class="token punctuation" >.</span>isRequired<span class="token punctuation" >,</span>
|
||
products<span class="token punctuation" >:</span> PropTypes<span class="token punctuation" >.</span>array<span class="token punctuation" >.</span>isRequired<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> ProductList<span class="token punctuation" >;</span></code></pre><h2 id="定义-Model" data-reactid="448"><span data-reactid="449"><!-- react-text: 450 -->定义 Model<!-- /react-text --></span><a href="#定义-Model" class="anchor" data-reactid="451">#</a></h2><p data-reactid="452"><!-- react-text: 453 -->完成 UI 后,现在开始处理数据和逻辑。<!-- /react-text --></p><p data-reactid="454"><!-- react-text: 455 -->dva 通过 model 的概念把一个领域的模型管理起来,包含同步更新 state 的 reducers,处理异步逻辑的 effects,订阅数据源的 subscriptions 。<!-- /react-text --></p><p data-reactid="456"><!-- react-text: 457 -->新建 model <!-- /react-text --><code data-reactid="458"><!-- react-text: 459 -->models/products.js<!-- /react-text --></code><!-- react-text: 460 --> :<!-- /react-text --></p><pre class="language-javascript" data-reactid="461"><code data-reactid="462"><span class="token keyword" >import</span> dva <span class="token keyword" >from</span> <span class="token string" >'dva'</span><span class="token punctuation" >;</span>
|
||
|
||
<span class="token keyword" >export</span> <span class="token keyword" >default</span> <span class="token punctuation" >{</span>
|
||
namespace<span class="token punctuation" >:</span> <span class="token string" >'products'</span><span class="token punctuation" >,</span>
|
||
state<span class="token punctuation" >:</span> <span class="token punctuation" >[</span><span class="token punctuation" >]</span><span class="token punctuation" >,</span>
|
||
reducers<span class="token punctuation" >:</span> <span class="token punctuation" >{</span>
|
||
<span class="token string" >'delete'</span><span class="token punctuation" >(</span>state<span class="token punctuation" >,</span> <span class="token punctuation" >{</span> payload<span class="token punctuation" >:</span> id <span class="token punctuation" >}</span><span class="token punctuation" >)</span> <span class="token punctuation" >{</span>
|
||
<span class="token keyword" >return</span> state<span class="token punctuation" >.</span><span class="token function" >filter</span><span class="token punctuation" >(</span>item <span class="token operator" >=</span><span class="token operator" >></span> item<span class="token punctuation" >.</span>id <span class="token operator" >!==</span> id<span class="token punctuation" >)</span><span class="token punctuation" >;</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >,</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >,</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >;</span></code></pre><p data-reactid="463"><!-- react-text: 464 -->这个 model 里:<!-- /react-text --></p><ul data-reactid="465"><li data-reactid="466"><p data-reactid="467"><code data-reactid="468"><!-- react-text: 469 -->namespace<!-- /react-text --></code><!-- react-text: 470 --> 表示在全局 state 上的 key<!-- /react-text --></p></li><li data-reactid="471"><p data-reactid="472"><code data-reactid="473"><!-- react-text: 474 -->state<!-- /react-text --></code><!-- react-text: 475 --> 是初始值,在这里是空数组<!-- /react-text --></p></li><li data-reactid="476"><p data-reactid="477"><code data-reactid="478"><!-- react-text: 479 -->reducers<!-- /react-text --></code><!-- react-text: 480 --> 等同于 redux 里的 reducer,接收 action,同步更新 state<!-- /react-text --></p></li></ul><p data-reactid="481"><!-- react-text: 482 -->然后别忘记在 <!-- /react-text --><code data-reactid="483"><!-- react-text: 484 -->index.js<!-- /react-text --></code><!-- react-text: 485 --> 里载入他:<!-- /react-text --></p><pre class="language-diff" data-reactid="486"><code data-reactid="487">// 3. Model
|
||
<span class="token inserted" >+ app.model(require('./models/products'));</span></code></pre><h2 id="connect-起来" data-reactid="488"><span data-reactid="489"><!-- react-text: 490 -->connect 起来<!-- /react-text --></span><a href="#connect-起来" class="anchor" data-reactid="491">#</a></h2><p data-reactid="492"><!-- react-text: 493 -->到这里,我们已经单独完成了 model 和 component,那么他们如何串联起来呢?<!-- /react-text --></p><p data-reactid="494"><!-- react-text: 495 -->dva 提供了 connect 方法。如果你熟悉 redux,这个 connect 就是 react-redux 的 connect 。<!-- /react-text --></p><p data-reactid="496"><!-- react-text: 497 -->编辑 <!-- /react-text --><code data-reactid="498"><!-- react-text: 499 -->routes/Products.js<!-- /react-text --></code><!-- react-text: 500 -->,替换为以下内容:<!-- /react-text --></p><pre class="language-javascript" data-reactid="501"><code data-reactid="502"><span class="token keyword" >import</span> React <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> connect <span class="token punctuation" >}</span> <span class="token keyword" >from</span> <span class="token string" >'dva'</span><span class="token punctuation" >;</span>
|
||
<span class="token keyword" >import</span> ProductList <span class="token keyword" >from</span> <span class="token string" >'../components/ProductList'</span><span class="token punctuation" >;</span>
|
||
|
||
<span class="token keyword" >const</span> Products <span class="token operator" >=</span> <span class="token punctuation" >(</span><span class="token punctuation" >{</span> dispatch<span class="token punctuation" >,</span> products <span class="token punctuation" >}</span><span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation" >{</span>
|
||
<span class="token keyword" >function</span> <span class="token function" >handleDelete</span><span class="token punctuation" >(</span>id<span class="token punctuation" >)</span> <span class="token punctuation" >{</span>
|
||
<span class="token function" >dispatch</span><span class="token punctuation" >(</span><span class="token punctuation" >{</span>
|
||
type<span class="token punctuation" >:</span> <span class="token string" >'products/delete'</span><span class="token punctuation" >,</span>
|
||
payload<span class="token punctuation" >:</span> id<span class="token punctuation" >,</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" >return</span> <span class="token punctuation" >(</span>
|
||
<span class="token operator" ><</span>div<span class="token operator" >></span>
|
||
<span class="token operator" ><</span>h2<span class="token operator" >></span>List <span class="token keyword" >of</span> Products<span class="token operator" ><</span><span class="token operator" >/</span>h2<span class="token operator" >></span>
|
||
<span class="token operator" ><</span>ProductList onDelete<span class="token operator" >=</span><span class="token punctuation" >{</span>handleDelete<span class="token punctuation" >}</span> products<span class="token operator" >=</span><span class="token punctuation" >{</span>products<span class="token punctuation" >}</span> <span class="token operator" >/</span><span class="token operator" >></span>
|
||
<span class="token operator" ><</span><span class="token operator" >/</span>div<span class="token operator" >></span>
|
||
<span class="token punctuation" >)</span><span class="token punctuation" >;</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >;</span>
|
||
|
||
<span class="token comment" spellcheck="true">// export default Products;</span>
|
||
<span class="token keyword" >export</span> <span class="token keyword" >default</span> <span class="token function" >connect</span><span class="token punctuation" >(</span><span class="token punctuation" >(</span><span class="token punctuation" >{</span> products <span class="token punctuation" >}</span><span class="token punctuation" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation" >(</span><span class="token punctuation" >{</span>
|
||
products<span class="token punctuation" >,</span>
|
||
<span class="token punctuation" >}</span><span class="token punctuation" >)</span><span class="token punctuation" >)</span><span class="token punctuation" >(</span>Products<span class="token punctuation" >)</span><span class="token punctuation" >;</span></code></pre><p data-reactid="503"><!-- react-text: 504 -->最后,我们还需要一些初始数据让这个应用 run 起来。编辑 <!-- /react-text --><code data-reactid="505"><!-- react-text: 506 -->index.js<!-- /react-text --></code><!-- react-text: 507 -->:<!-- /react-text --></p><pre class="language-diff" data-reactid="508"><code data-reactid="509"><span class="token deleted" >- const app = dva();</span>
|
||
<span class="token inserted" >+ const app = dva({</span>
|
||
<span class="token inserted" >+ initialState: {</span>
|
||
<span class="token inserted" >+ products: [</span>
|
||
<span class="token inserted" >+ { name: 'dva', id: 1 },</span>
|
||
<span class="token inserted" >+ { name: 'antd', id: 2 },</span>
|
||
<span class="token inserted" >+ ],</span>
|
||
<span class="token inserted" >+ },</span>
|
||
<span class="token inserted" >+ });</span></code></pre><p data-reactid="510"><!-- react-text: 511 -->刷新浏览器,应该能看到以下效果:<!-- /react-text --></p><p style="text-align:center;" data-reactid="512"><img src="https://zos.alipayobjects.com/rmsportal/GQJeDDeUCSTRMMg.gif" data-reactid="513"/></p><h2 id="构建应用" data-reactid="514"><span data-reactid="515"><!-- react-text: 516 -->构建应用<!-- /react-text --></span><a href="#构建应用" class="anchor" data-reactid="517">#</a></h2><p data-reactid="518"><!-- react-text: 519 -->完成开发并且在开发环境验证之后,就需要部署给我们的用户了。先执行下面的命令:<!-- /react-text --></p><pre class="language-bash" data-reactid="520"><code data-reactid="521">$ npm run build</code></pre><p data-reactid="522"><!-- react-text: 523 -->几秒后,输出应该如下:<!-- /react-text --></p><pre class="language-bash" data-reactid="524"><code data-reactid="525">Child
|
||
Time: 14008ms
|
||
Asset Size Chunks Chunk Names
|
||
index.html 255 bytes <span class="token punctuation" >[</span>emitted<span class="token punctuation" >]</span>
|
||
common.js 1.18 kB 0 <span class="token punctuation" >[</span>emitted<span class="token punctuation" >]</span> common
|
||
index.js 504 kB 1, 0 <span class="token punctuation" >[</span>emitted<span class="token punctuation" >]</span> index
|
||
index.css 127 kB 1, 0 <span class="token punctuation" >[</span>emitted<span class="token punctuation" >]</span> index</code></pre><p data-reactid="526"><code data-reactid="527"><!-- react-text: 528 -->build<!-- /react-text --></code><!-- react-text: 529 --> 命令会打包所有的资源,包含 JavaScript, CSS, web fonts, images, html 等。然后你可以在 <!-- /react-text --><code data-reactid="530"><!-- react-text: 531 -->dist/<!-- /react-text --></code><!-- react-text: 532 --> 目录下找到这些文件。<!-- /react-text --></p><h2 id="下一步" data-reactid="533"><span data-reactid="534"><!-- react-text: 535 -->下一步<!-- /react-text --></span><a href="#下一步" class="anchor" data-reactid="536">#</a></h2><p data-reactid="537"><!-- react-text: 538 -->我们已经完成了一个简单应用,你可能还有很多疑问,比如:<!-- /react-text --></p><ul data-reactid="539"><li data-reactid="540"><p data-reactid="541"><!-- react-text: 542 -->如何处理异步请求<!-- /react-text --></p></li><li data-reactid="543"><p data-reactid="544"><!-- react-text: 545 -->如何优雅地加载初始数据<!-- /react-text --></p></li><li data-reactid="546"><p data-reactid="547"><!-- react-text: 548 -->如何统一处理出错,以及特定操作的出错<!-- /react-text --></p></li><li data-reactid="549"><p data-reactid="550"><!-- react-text: 551 -->如何动态加载路由和 Model,以加速页面载入速度<!-- /react-text --></p></li><li data-reactid="552"><p data-reactid="553"><!-- react-text: 554 -->如何实现 hmr<!-- /react-text --></p></li><li data-reactid="555"><p data-reactid="556"><!-- react-text: 557 -->如何 mock 数据<!-- /react-text --></p></li><li data-reactid="558"><p data-reactid="559"><!-- react-text: 560 -->等等<!-- /react-text --></p></li></ul><p data-reactid="561"><!-- react-text: 562 -->你可以:<!-- /react-text --></p><ul data-reactid="563"><li data-reactid="564"><p data-reactid="565"><!-- react-text: 566 -->访问 <!-- /react-text --><a href="https://github.com/dvajs/dva" data-reactid="567"><!-- react-text: 568 -->dva 官网<!-- /react-text --></a><!-- react-text: 569 -->。<!-- /react-text --></p></li><li data-reactid="570"><p data-reactid="571"><!-- react-text: 572 -->查看所有 <!-- /react-text --><a href="https://github.com/dvajs/dva#api" data-reactid="573"><!-- react-text: 574 -->API<!-- /react-text --></a><!-- react-text: 575 -->。<!-- /react-text --></p></li><li data-reactid="576"><p data-reactid="577"><a href="https://github.com/dvajs/dva-docs/blob/master/v1/zh-cn/tutorial/01-%E6%A6%82%E8%A6%81.md" data-reactid="578"><!-- react-text: 579 -->教程<!-- /react-text --></a><!-- react-text: 580 -->,一步步完成一个中型应用。<!-- /react-text --></p></li><li data-reactid="581"><p data-reactid="582"><!-- react-text: 583 -->看看 <!-- /react-text --><a href="https://github.com/dvajs/dva-hackernews" data-reactid="584"><!-- react-text: 585 -->dva 版 hackernews<!-- /react-text --></a><!-- react-text: 586 --> 是 <!-- /react-text --><a href="https://github.com/sorrycc/blog/issues/9" data-reactid="587"><!-- react-text: 588 -->如何实现<!-- /react-text --></a><!-- react-text: 589 --> 的。<!-- /react-text --></p></li></ul></section></article></div></div><div class="ant-row" data-reactid="590"><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="591"><section class="prev-next-nav" data-reactid="592"><a class="prev-page" href="/docs/react/install-cn" data-reactid="593">安装</a><a class="next-page" href="/docs/react/customize-theme-cn" data-reactid="594">定制主题</a></section></div></div></div><footer id="footer" data-reactid="595"><ul data-reactid="596"><li data-reactid="597"><h2 data-reactid="598">GitHub</h2><div data-reactid="599"><a target="_blank " href="https://github.com/ant-design/ant-design" data-reactid="600"><span data-reactid="601">仓库</span></a></div><div data-reactid="602"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva" data-reactid="603">dva</a><!-- react-text: 604 --> - <!-- /react-text --><span data-reactid="605">应用框架</span></div><div data-reactid="606"><a target="_blank" rel="noopener noreferrer" href="https://github.com/dvajs/dva-cli" data-reactid="607">dva-cli</a><!-- react-text: 608 --> -<!-- /react-text --><span data-reactid="609">脚手架</span></div><div data-reactid="610"><a target="_blank" rel="noopener noreferrer" href="http://ant-tool.github.io" data-reactid="611">ant-tool</a><!-- react-text: 612 --> - <!-- /react-text --><span data-reactid="613">开发工具</span></div></li><li data-reactid="614"><h2 data-reactid="615"><span data-reactid="616">相关站点</span></h2><div data-reactid="617"><a href="http://mobile.ant.design" data-reactid="618">Ant Design Mobile</a><span data-reactid="619"> - </span><span data-reactid="620">移动版</span></div><div data-reactid="621"><a href="https://g2.alipay.com/" data-reactid="622">G2</a><span data-reactid="623"> - </span><span data-reactid="624">数据可视化</span></div><div data-reactid="625"><a href="https://antv.alipay.com/" data-reactid="626">AntV</a><span data-reactid="627"> - </span><span data-reactid="628">数据可视化规范</span></div><div data-reactid="629"><a href="http://motion.ant.design" data-reactid="630">Ant Motion</a><span data-reactid="631"> - </span><span data-reactid="632">设计动效</span></div><div data-reactid="633"><a href="http://library.ant.design/" data-reactid="634">AntD Library</a><span data-reactid="635"> - </span><span data-reactid="636">Axure 部件库</span></div><div data-reactid="637"><a href="http://ux.ant.design" data-reactid="638">Ant UX</a><span data-reactid="639"> - </span><span data-reactid="640">页面逻辑素材</span></div></li><li data-reactid="641"><h2 data-reactid="642"><span data-reactid="643">社区</span></h2><div data-reactid="644"><a rel="noopener noreferrer" href="/changelog" data-reactid="645"><span data-reactid="646">更新记录</span></a></div><div data-reactid="647"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/issues" data-reactid="648"><span data-reactid="649">反馈和建议</span></a></div><div data-reactid="650"><a target="_blank" rel="noopener noreferrer" href="https://gitter.im/ant-design/ant-design" data-reactid="651"><span data-reactid="652">讨论</span></a></div><div data-reactid="653"><a target="_blank" rel="noopener noreferrer" href="https://github.com/ant-design/ant-design/issues/new" data-reactid="654"><span data-reactid="655">报告 Bug</span></a></div></li><li data-reactid="656"><div data-reactid="657"><!-- react-text: 658 -->©2016 <!-- /react-text --><span data-reactid="659">蚂蚁金服体验技术部出品</span></div><div data-reactid="660"><!-- react-text: 661 -->Powered by <!-- /react-text --><a href="https://github.com/benjycui/bisheng" data-reactid="662">BiSheng</a></div><div style="margin-top:10px;" data-reactid="663"><span data-reactid="664">文档版本:</span><div class="ant-select-sm ant-select ant-select-enabled" data-reactid="665"><div class="ant-select-selection
|
||
ant-select-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" tabindex="0" data-reactid="666"><div class="ant-select-selection__rendered" data-reactid="667"><div class="ant-select-selection-selected-value" title="1.11.4" style="display:block;opacity:1;" data-reactid="668">1.11.4</div></div><span class="ant-select-arrow" style="user-select:none;-webkit-user-select:none;" unselectable="unselectable" data-reactid="669"><b data-reactid="670"></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>
|