Files
ant-design/components/collapse/index.html
T
2015-07-22 15:35:36 +08:00

784 lines
26 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="一个设计&前端框架"/>
<title>
Collapse 折叠面板 - Ant Design
</title>
<link rel="icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
<link rel="shortcut icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
<link rel="stylesheet" href="/dist/antd-0.7.1.css">
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="/static/tomorrow.css">
<script>
(function (con) {
'use strict';
var prop, method;
var empty = {};
var dummy = function () {
};
var properties = 'memory'.split(',');
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
while (prop = properties.pop()) {
con[prop] = con[prop] || empty;
}
while (method = methods.pop()) {
con[method] = con[method] || dummy;
}
})(this.console = this.console || {});
</script>
<script src="https://a.alipayobjects.com/??bluebird/2.9.30/bluebird.js,jquery/jquery/1.11.1/jquery.js,es5-shim/4.0.5/es5-shim-debug.js,es5-shim/4.0.5/es5-sham-debug.js,html5shiv/3.7.2/src/html5shiv.js,react/0.13.3/react.js,react-router/0.13.3/ReactRouter.js"></script>
<script>
var ANT_COMPONENTS = [];
ANT_COMPONENTS.push({
title: 'Layout',
desc: '布局'
});
ANT_COMPONENTS.push({
title: 'Checkbox',
desc: '多选框'
});
ANT_COMPONENTS.push({
title: 'Iconfont',
desc: '字体图标'
});
ANT_COMPONENTS.push({
title: 'Button',
desc: '按钮'
});
ANT_COMPONENTS.push({
title: 'Radio',
desc: '单选框'
});
ANT_COMPONENTS.push({
title: 'Form',
desc: '表单'
});
ANT_COMPONENTS.push({
title: 'Switch',
desc: '开关'
});
ANT_COMPONENTS.push({
title: 'InputNumber',
desc: '数字输入框'
});
ANT_COMPONENTS.push({
title: 'Motion',
desc: '组件动画'
});
ANT_COMPONENTS.push({
title: 'Slider',
desc: '滑动输入条'
});
ANT_COMPONENTS.push({
title: 'Datepicker',
desc: '日期选择框'
});
ANT_COMPONENTS.push({
title: 'Select',
desc: '选择器'
});
ANT_COMPONENTS.push({
title: 'Tabs',
desc: '标签页'
});
ANT_COMPONENTS.push({
title: 'Steps',
desc: '步骤条'
});
ANT_COMPONENTS.push({
title: 'Breadcrumb',
desc: '面包屑'
});
ANT_COMPONENTS.push({
title: 'Collapse',
desc: '折叠面板'
});
ANT_COMPONENTS.push({
title: 'Alert',
desc: '通知栏'
});
ANT_COMPONENTS.push({
title: 'Notification',
desc: '系统通知框'
});
ANT_COMPONENTS.push({
title: 'Pagination',
desc: '分页'
});
ANT_COMPONENTS.push({
title: 'Tree',
desc: '树形控件'
});
ANT_COMPONENTS.push({
title: 'Carousel',
desc: '走马灯'
});
ANT_COMPONENTS.push({
title: 'Menu',
desc: '导航菜单'
});
ANT_COMPONENTS.push({
title: 'Tag',
desc: '标签'
});
ANT_COMPONENTS.push({
title: 'Affix',
desc: '固定'
});
ANT_COMPONENTS.push({
title: 'Upload',
desc: '文件上传'
});
ANT_COMPONENTS.push({
title: 'Modal',
desc: '对话框'
});
ANT_COMPONENTS.push({
title: 'Message',
desc: '全局提示'
});
ANT_COMPONENTS.push({
title: 'Dropdown',
desc: '下拉菜单'
});
ANT_COMPONENTS.push({
title: 'Popover',
desc: '气泡卡片'
});
ANT_COMPONENTS.push({
title: 'Popconfirm',
desc: '气泡确认框'
});
ANT_COMPONENTS.push({
title: 'Tooltip',
desc: '文字提示'
});
ANT_COMPONENTS.push({
title: 'Progress',
desc: '进度条'
});
ANT_COMPONENTS.push({
title: 'Table',
desc: '表格'
});
</script>
<script src="/static/script.js"></script>
<script>
window.antdVersion = {
latest: '0.7.1',
stable: '0.7.0'
};
</script>
<script src="/dist/antd-0.7.1.js"></script>
<script src="/dist/demo.js"></script>
<script>
window.require = function (path) {
var result = window;
var namespaces = path.split('/');
namespaces.forEach(function (key, i) {
if (i !== 0 && i === namespaces.length - 1) {
key = capitalizeFirstLetter(key);
}
if (key !== 'lib') {
if (result[key]) {
result = result[key];
} else {
throw 'There should not have modules here 2.';
}
}
});
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
return result;
};
</script>
</head>
<body >
<header id="header">
<a class="logo" href="/">
<img width="60" src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg">
Ant Design
</a>
<div class="search">
<div id="autoComplete"></div>
</div>
<nav class="nav">
<span class="bar"></span>
<ul>
<li class="">
<a href="/">首页</a>
</li>
<li class="">
<a href="/docs/introduce">使用</a>
</li>
<li class="">
<a class="disabled" href="/design/">设计</a>
</li>
<li class="current">
<a href="/components">组件</a>
</li>
<li>
<a target="_blank" href="https://github.com/ant-design/ant-design">Github</a>
</li>
</ul>
</nav>
</header>
<div class="main-wrapper">
<aside class="aside-container">
<ul>
<li>
<h4>CSS</h4>
<ul class="">
<li class="">
<a href="../layout/">
Layout
<span class="chinese">布局</span>
</a>
</li>
<li class="">
<a href="../iconfont/">
Iconfont
<span class="chinese">字体图标</span>
</a>
</li>
<li class="">
<a href="../button/">
Button
<span class="chinese">按钮</span>
</a>
</li>
<li class="">
<a href="../form/">
Form
<span class="chinese">表单</span>
</a>
</li>
<li class="">
<a href="../motion/">
Motion
<span class="chinese">组件动画</span>
</a>
</li>
<li class="">
<a href="../alert/">
Alert
<span class="chinese">通知栏</span>
</a>
</li>
</ul>
</li>
<li>
<h4>Components</h4>
<ul class="aside-list-show">
<li class="">
<a href="../checkbox/">
Checkbox
<span class="chinese">多选框</span>
</a>
</li>
<li class="">
<a href="../radio/">
Radio
<span class="chinese">单选框</span>
</a>
</li>
<li class="">
<a href="../switch/">
Switch
<span class="chinese">开关</span>
</a>
</li>
<li class="">
<a href="../slider/">
Slider
<span class="chinese">滑动输入条</span>
</a>
</li>
<li class="">
<a href="../input-number/">
InputNumber
<span class="chinese">数字输入框</span>
</a>
</li>
<li class="">
<a href="../select/">
Select
<span class="chinese">选择器</span>
</a>
</li>
<li class="">
<a href="../datepicker/">
Datepicker
<span class="chinese">日期选择框</span>
</a>
</li>
<li class="">
<a href="../tabs/">
Tabs
<span class="chinese">标签页</span>
</a>
</li>
<li class="">
<a href="../steps/">
Steps
<span class="chinese">步骤条</span>
</a>
</li>
<li class="">
<a href="../breadcrumb/">
Breadcrumb
<span class="chinese">面包屑</span>
</a>
</li>
<li class="current">
<a href="./">
Collapse
<span class="chinese">折叠面板</span>
</a>
</li>
<li class="">
<a href="../affix/">
Affix
<span class="chinese">固定</span>
</a>
</li>
<li class="">
<a href="../pagination/">
Pagination
<span class="chinese">分页</span>
</a>
</li>
<li class="">
<a href="../tree/">
Tree
<span class="chinese">树形控件</span>
</a>
</li>
<li class="">
<a href="../carousel/">
Carousel
<span class="chinese">走马灯</span>
</a>
</li>
<li class="">
<a href="../menu/">
Menu
<span class="chinese">导航菜单</span>
</a>
</li>
<li class="">
<a href="../tag/">
Tag
<span class="chinese">标签</span>
</a>
</li>
<li class="">
<a href="../upload/">
Upload
<span class="chinese">文件上传</span>
</a>
</li>
<li class="">
<a href="../notification/">
Notification
<span class="chinese">系统通知框</span>
</a>
</li>
<li class="">
<a href="../modal/">
Modal
<span class="chinese">对话框</span>
</a>
</li>
<li class="">
<a href="../message/">
Message
<span class="chinese">全局提示</span>
</a>
</li>
<li class="">
<a href="../dropdown/">
Dropdown
<span class="chinese">下拉菜单</span>
</a>
</li>
<li class="">
<a href="../popover/">
Popover
<span class="chinese">气泡卡片</span>
</a>
</li>
<li class="">
<a href="../popconfirm/">
Popconfirm
<span class="chinese">气泡确认框</span>
</a>
</li>
<li class="">
<a href="../tooltip/">
Tooltip
<span class="chinese">文字提示</span>
</a>
</li>
<li class="">
<a href="../progress/">
Progress
<span class="chinese">进度条</span>
</a>
</li>
<li class="">
<a href="../table/">
Table
<span class="chinese">表格</span>
</a>
</li>
</ul>
</li>
</ul>
</aside>
<section class="main-container">
<article class="markdown">
<h1>
Collapse 折叠面板
</h1>
<p>可以折叠/展开的内容区域。</p>
<h2 id="何时使用">何时使用</h2><ul>
<li>对复杂区域进行分组和隐藏,保持页面的整洁。</li>
<li><code>手风琴</code> 是一种特殊的折叠面板,只允许单个内容区域展开。</li>
</ul>
<h2 id="api">API</h2><h3 id="collapse">Collapse</h3><table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
<th>类型</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td>activeKey</td>
<td>当前激活 tab 面板的 key</td>
<td>Array or String</td>
<td>默认无,accordion模式下默认第一个元素</td>
</tr>
<tr>
<td>defaultActiveKey</td>
<td>初始化选中面板的 key</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>onChange</td>
<td>切换面板的回调</td>
<td>Function</td>
<td></td>
</tr>
</tbody>
</table>
<h3 id="collapse-panel">Collapse.Panel</h3><table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
<th>类型</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td>key</td>
<td>对应 activeKey</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>header</td>
<td>面板头内容</td>
<td>React.Element or String</td>
<td></td>
</tr>
</tbody>
</table>
</article><h2 class="component-demos">
组件演示
<i class="iconfont-home icon-all" title="展开全部代码"></i>
</h2>
<div class="code-boxes clearfix">
<div class="code-boxes-col-2-1"><div class="code-box">
<div class="code-box-demo">
<div id="components-collapse-demo-basic"></div>
<script>(function(){"use strict";
var Collapse = antd.Collapse;
var Panel = Collapse.Panel;
function callback(key) {
console.log(key);
}
var text = "\n A dog is a type of domesticated animal.\n Known for its loyalty and faithfulness,\n it can be found as a welcome guest in many households across the world.\n";
React.render(React.createElement(
Collapse,
{ defaultActiveKey: ["1"], onChange: callback },
React.createElement(
Panel,
{ header: "This is panel header 1", key: "1" },
React.createElement(
"p",
null,
text
)
),
React.createElement(
Panel,
{ header: "This is panel header 2", key: "2" },
React.createElement(
"p",
null,
text
)
),
React.createElement(
Panel,
{ header: "This is panel header 3", key: "3" },
React.createElement(
"p",
null,
text
)
)
), document.getElementById('components-collapse-demo-basic'));})()</script><div class="highlight"><pre><code class="javascript"><span class="keyword">var</span> Collapse = antd.Collapse;
<span class="keyword">var</span> Panel = Collapse.Panel;
<span class="function"><span class="keyword">function</span> <span class="title">callback</span><span class="params">(key)</span> {</span>
console.log(key);
}
<span class="keyword">var</span> text = `
A dog is a type of domesticated animal.
Known <span class="keyword">for</span> its loyalty and faithfulness,
it can be found as a welcome guest <span class="keyword">in</span> many households across the world.
`;
React.render(
<span class="xml"><span class="tag">&lt;<span class="title">Collapse</span> <span class="attribute">defaultActiveKey</span>=<span class="value">{["1"]}</span> <span class="attribute">onChange</span>=<span class="value">{callback}</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">1</span>`} <span class="attribute">key</span>=<span class="value">"1"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">2</span>`} <span class="attribute">key</span>=<span class="value">"2"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">3</span>`} <span class="attribute">key</span>=<span class="value">"3"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Collapse</span>&gt;</span>
, document.getElementById('components-collapse-demo-basic'));</span></code></pre></div>
</div>
<div class="code-box-meta markdown">
<div class="code-box-title">折叠面板</div>
<p>可以同时展开多个面板,这个例子默认展开了第一个。</p>
<span class="collapse anticon anticon-circle-o-right"></span>
</div>
</div><div class="code-box">
<div class="code-box-demo">
<div id="components-collapse-demo-mix"></div>
<script>(function(){"use strict";
var Collapse = antd.Collapse;
var Panel = Collapse.Panel;
function callback(key) {
console.log(key);
}
var text = "\n A dog is a type of domesticated animal.\n Known for its loyalty and faithfulness,\n it can be found as a welcome guest in many households across the world.\n";
React.render(React.createElement(
Collapse,
{ onChange: callback, accordion: true },
React.createElement(
Panel,
{ header: "This is panel header 1", key: "1" },
React.createElement(
Collapse,
{ defaultActiveKey: "1" },
React.createElement(
Panel,
{ header: "This is panel nest panel", key: "1" },
React.createElement(
"p",
null,
text
)
)
)
),
React.createElement(
Panel,
{ header: "This is panel header 2", key: "2" },
React.createElement(
"p",
null,
text
)
),
React.createElement(
Panel,
{ header: "This is panel header 3", key: "3" },
React.createElement(
"p",
null,
text
)
)
), document.getElementById('components-collapse-demo-mix'));})()</script><div class="highlight"><pre><code class="javascript"><span class="keyword">var</span> Collapse = antd.Collapse;
<span class="keyword">var</span> Panel = Collapse.Panel;
<span class="function"><span class="keyword">function</span> <span class="title">callback</span><span class="params">(key)</span> {</span>
console.log(key);
}
<span class="keyword">var</span> text = `
A dog is a type of domesticated animal.
Known <span class="keyword">for</span> its loyalty and faithfulness,
it can be found as a welcome guest <span class="keyword">in</span> many households across the world.
`;
React.render(
<span class="xml"><span class="tag">&lt;<span class="title">Collapse</span> <span class="attribute">onChange</span>=<span class="value">{callback}</span> <span class="attribute">accordion</span>=<span class="value">{true}</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">1</span>`} <span class="attribute">key</span>=<span class="value">"1"</span>&gt;</span>
<span class="tag">&lt;<span class="title">Collapse</span> <span class="attribute">defaultActiveKey</span>=<span class="value">"1"</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">nest</span> <span class="attribute">panel</span>`} <span class="attribute">key</span>=<span class="value">"1"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Collapse</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">2</span>`} <span class="attribute">key</span>=<span class="value">"2"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">3</span>`} <span class="attribute">key</span>=<span class="value">"3"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Collapse</span>&gt;</span>
, document.getElementById('components-collapse-demo-mix'));</span></code></pre></div>
</div>
<div class="code-box-meta markdown">
<div class="code-box-title">面板嵌套</div>
<p>手风琴嵌套折叠面板。</p>
<span class="collapse anticon anticon-circle-o-right"></span>
</div>
</div>
</div>
<div class="code-boxes-col-2-1"><div class="code-box">
<div class="code-box-demo">
<div id="components-collapse-demo-accordion"></div>
<script>(function(){"use strict";
var Collapse = antd.Collapse;
var Panel = Collapse.Panel;
var text = "\n A dog is a type of domesticated animal.\n Known for its loyalty and faithfulness,\n it can be found as a welcome guest in many households across the world.\n";
React.render(React.createElement(
Collapse,
{ accordion: true },
React.createElement(
Panel,
{ header: "This is panel header 1", key: "1" },
React.createElement(
"p",
null,
text
)
),
React.createElement(
Panel,
{ header: "This is panel header 2", key: "2" },
React.createElement(
"p",
null,
text
)
),
React.createElement(
Panel,
{ header: "This is panel header 3", key: "3" },
React.createElement(
"p",
null,
text
)
)
), document.getElementById('components-collapse-demo-accordion'));})()</script><div class="highlight"><pre><code class="javascript"><span class="keyword">var</span> Collapse = antd.Collapse;
<span class="keyword">var</span> Panel = Collapse.Panel;
<span class="keyword">var</span> text = `
A dog is a type of domesticated animal.
Known <span class="keyword">for</span> its loyalty and faithfulness,
it can be found as a welcome guest <span class="keyword">in</span> many households across the world.
`;
React.render(
<span class="xml"><span class="tag">&lt;<span class="title">Collapse</span> <span class="attribute">accordion</span>=<span class="value">{true}</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">1</span>`} <span class="attribute">key</span>=<span class="value">"1"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">2</span>`} <span class="attribute">key</span>=<span class="value">"2"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;<span class="title">Panel</span> <span class="attribute">header</span>=<span class="value">{`This</span> <span class="attribute">is</span> <span class="attribute">panel</span> <span class="attribute">header</span> <span class="attribute">3</span>`} <span class="attribute">key</span>=<span class="value">"3"</span>&gt;</span>
<span class="tag">&lt;<span class="title">p</span>&gt;</span>{text}<span class="tag">&lt;/<span class="title">p</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Panel</span>&gt;</span>
<span class="tag">&lt;/<span class="title">Collapse</span>&gt;</span>
, document.getElementById('components-collapse-demo-accordion'));</span></code></pre></div>
</div>
<div class="code-box-meta markdown">
<div class="code-box-title">手风琴</div>
<p>手风琴,每次只打开一个tab。默认打开第一个。</p>
<span class="collapse anticon anticon-circle-o-right"></span>
</div>
</div>
</div>
</div>
</section>
</div><footer id="footer">
<ul>
<li>
<h2>GitHub</h2>
<a target="_blank "href="https://github.com/ant-design/ant-design">仓库</a>
<a target="_blank" href="https://github.com/ant-design/ant-design/tree/master/style">样式</a>
<a target="_blank" href="https://github.com/ant-design/antd-bin">开发工具</a>
</li>
<li>
<h2>关于我们</h2>
<a href="http://www.atatech.org/teams/79">博客 - Ant UED</a>
</li>
<li>
<h2>联系我们</h2>
<a target="_blank" href="https://github.com/ant-design/ant-design/issues">问题与建议 - Issues</a>
</li>
<li>
<h3>©2015 蚂蚁金服体验技术部出品</h3>
</li>
</ul>
</footer>
</body>
</html>