mirror of
https://github.com/wahyd4/ant-design.git
synced 2026-08-22 19:28:47 +10:00
1553 lines
63 KiB
HTML
1553 lines
63 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="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="一个 UI 设计语言"/>
|
|
<title>
|
|
Button 按钮 - 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/demo.css?20160114">
|
|
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.1.14/es5-shim.min.js,es5-shim/4.1.14/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js,jquery/1.11.3/jquery.min.js,bluebird/3.1.1/bluebird.min.js"></script>
|
|
<script>
|
|
(function() {
|
|
window.ANT_COMPONENTS = [];
|
|
window.InstantClickChangeFns = [];
|
|
ANT_COMPONENTS.push({
|
|
title: 'Pagination',
|
|
desc: '分页'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Affix',
|
|
desc: '固钉'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Badge',
|
|
desc: '徽标数'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Breadcrumb',
|
|
desc: '面包屑'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Button',
|
|
desc: '按钮'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Calendar',
|
|
desc: '日历'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Carousel',
|
|
desc: '走马灯'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Cascader',
|
|
desc: '级联选择'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Checkbox',
|
|
desc: '多选框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Collapse',
|
|
desc: '折叠面板'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'DatePicker',
|
|
desc: '日期选择框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Dropdown',
|
|
desc: '下拉菜单'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Form',
|
|
desc: '表单'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Icon',
|
|
desc: '图标'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'InputNumber',
|
|
desc: '数字输入框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Layout',
|
|
desc: '布局'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Menu',
|
|
desc: '导航菜单'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Message',
|
|
desc: '全局提示'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Modal',
|
|
desc: '对话框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Notification',
|
|
desc: '通知提醒框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Alert',
|
|
desc: '警告提示'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Popconfirm',
|
|
desc: '气泡确认框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Popover',
|
|
desc: '气泡卡片'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Progress',
|
|
desc: '进度条'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'QueueAnim',
|
|
desc: '进出场动画'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Radio',
|
|
desc: '单选框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Select',
|
|
desc: '选择器'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Slider',
|
|
desc: '滑动输入条'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Spin',
|
|
desc: '加载中'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Steps',
|
|
desc: '步骤条'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Switch',
|
|
desc: '开关'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Table',
|
|
desc: '表格'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Tabs',
|
|
desc: '标签页'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Tag',
|
|
desc: '标签'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'TimePicker',
|
|
desc: '时间选择框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Timeline',
|
|
desc: '时间轴'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Tooltip',
|
|
desc: '文字提示'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Transfer',
|
|
desc: '穿梭框'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Tree',
|
|
desc: '树形控件'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'TreeSelect',
|
|
desc: '树选择'
|
|
});
|
|
ANT_COMPONENTS.push({
|
|
title: 'Upload',
|
|
desc: '文件上传'
|
|
});
|
|
// fix ie location origin
|
|
// http://stackoverflow.com/questions/22564167/window-location-origin-gives-wrong-value-when-using-ie
|
|
if (!window.location.origin) {
|
|
window.location.origin = window.location.protocol + "//"
|
|
+ window.location.hostname
|
|
+ (window.location.port ? ':' + window.location.port : '');
|
|
}
|
|
var i = location.pathname.split('/').lastIndexOf('ant-design');
|
|
if (i > 0) {
|
|
window.rootUrl = location.origin + location.pathname.split('/').slice(0, 2+1).join('/');
|
|
} else {
|
|
window.rootUrl = location.origin;
|
|
}
|
|
})();
|
|
</script>
|
|
<script>
|
|
window.antdVersion = {
|
|
latest: '0.12.8'
|
|
};
|
|
</script>
|
|
<script src="../../dist/demo.js?20160114"></script>
|
|
|
|
</head>
|
|
<body >
|
|
<header id="header" class="clearfix">
|
|
<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" tabindex="-1">
|
|
<span class="bar"></span>
|
|
<ul>
|
|
<li class="">
|
|
<a href="../..">首页</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/practice/cases">实践</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/pattern/navigation">模式</a>
|
|
</li>
|
|
<li class="current">
|
|
<a href="../../docs/react/introduce">组件</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/spec/introduce">语言</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/resource/download">资源</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<div class="nav-phone-icon"></div>
|
|
</header>
|
|
<div class="main-wrapper">
|
|
|
|
<aside class="aside-container">
|
|
<ul>
|
|
<li class="">
|
|
<a href="../../docs/react/introduce"
|
|
class="">
|
|
Ant Design of React
|
|
<span class="chinese"></span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/react/getting-started"
|
|
class="">
|
|
快速上手
|
|
<span class="chinese"></span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/react/install"
|
|
class="">
|
|
安装
|
|
<span class="chinese"></span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../docs/react/upgrade-notes"
|
|
class="">
|
|
升级指南
|
|
<span class="chinese"></span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../../changelog"
|
|
class="">
|
|
更新日志
|
|
<span class="chinese"></span>
|
|
</a>
|
|
</li>
|
|
<li open="open">
|
|
<h4>Components</h4>
|
|
<ul class="">
|
|
<li class="type-divider">基本</li>
|
|
<li class="current">
|
|
<a href="./"
|
|
class="">
|
|
Button
|
|
<span class="chinese">按钮</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../icon/"
|
|
class="">
|
|
Icon
|
|
<span class="chinese">图标</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../layout/"
|
|
class="">
|
|
Layout
|
|
<span class="chinese">布局</span>
|
|
</a>
|
|
</li>
|
|
<li class="type-divider">表单</li>
|
|
<li class="">
|
|
<a href="../cascader/"
|
|
class="">
|
|
Cascader
|
|
<span class="chinese">级联选择</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../checkbox/"
|
|
class="">
|
|
Checkbox
|
|
<span class="chinese">多选框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../date-picker/"
|
|
class="">
|
|
DatePicker
|
|
<span class="chinese">日期选择框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../form/"
|
|
class="">
|
|
Form
|
|
<span class="chinese">表单</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../input-number/"
|
|
class="">
|
|
InputNumber
|
|
<span class="chinese">数字输入框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../radio/"
|
|
class="">
|
|
Radio
|
|
<span class="chinese">单选框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../select/"
|
|
class="">
|
|
Select
|
|
<span class="chinese">选择器</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../slider/"
|
|
class="">
|
|
Slider
|
|
<span class="chinese">滑动输入条</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../switch/"
|
|
class="">
|
|
Switch
|
|
<span class="chinese">开关</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../time-picker/"
|
|
class="">
|
|
TimePicker
|
|
<span class="chinese">时间选择框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../transfer/"
|
|
class="">
|
|
Transfer
|
|
<span class="chinese">穿梭框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../tree-select/"
|
|
class="">
|
|
TreeSelect
|
|
<span class="chinese">树选择</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../upload/"
|
|
class="">
|
|
Upload
|
|
<span class="chinese">文件上传</span>
|
|
</a>
|
|
</li>
|
|
<li class="type-divider">展示</li>
|
|
<li class="">
|
|
<a href="../alert/"
|
|
class="">
|
|
Alert
|
|
<span class="chinese">警告提示</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../badge/"
|
|
class="">
|
|
Badge
|
|
<span class="chinese">徽标数</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../calendar/"
|
|
class="">
|
|
Calendar
|
|
<span class="chinese">日历</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../carousel/"
|
|
class="">
|
|
Carousel
|
|
<span class="chinese">走马灯</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../collapse/"
|
|
class="">
|
|
Collapse
|
|
<span class="chinese">折叠面板</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../dropdown/"
|
|
class="">
|
|
Dropdown
|
|
<span class="chinese">下拉菜单</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../message/"
|
|
class=""data-no-instant>
|
|
Message
|
|
<span class="chinese">全局提示</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../modal/"
|
|
class="">
|
|
Modal
|
|
<span class="chinese">对话框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../notification/"
|
|
class=""data-no-instant>
|
|
Notification
|
|
<span class="chinese">通知提醒框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../popconfirm/"
|
|
class="">
|
|
Popconfirm
|
|
<span class="chinese">气泡确认框</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../popover/"
|
|
class="">
|
|
Popover
|
|
<span class="chinese">气泡卡片</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../progress/"
|
|
class="">
|
|
Progress
|
|
<span class="chinese">进度条</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../table/"
|
|
class="">
|
|
Table
|
|
<span class="chinese">表格</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../tag/"
|
|
class="">
|
|
Tag
|
|
<span class="chinese">标签</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../timeline/"
|
|
class="">
|
|
Timeline
|
|
<span class="chinese">时间轴</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../tooltip/"
|
|
class="">
|
|
Tooltip
|
|
<span class="chinese">文字提示</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../tree/"
|
|
class="">
|
|
Tree
|
|
<span class="chinese">树形控件</span>
|
|
</a>
|
|
</li>
|
|
<li class="type-divider">导航</li>
|
|
<li class="">
|
|
<a href="../breadcrumb/"
|
|
class="">
|
|
Breadcrumb
|
|
<span class="chinese">面包屑</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../menu/"
|
|
class="">
|
|
Menu
|
|
<span class="chinese">导航菜单</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../pagination/"
|
|
class="">
|
|
Pagination
|
|
<span class="chinese">分页</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../steps/"
|
|
class="">
|
|
Steps
|
|
<span class="chinese">步骤条</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../tabs/"
|
|
class="">
|
|
Tabs
|
|
<span class="chinese">标签页</span>
|
|
</a>
|
|
</li>
|
|
<li class="type-divider">其他</li>
|
|
<li class="">
|
|
<a href="../affix/"
|
|
class="">
|
|
Affix
|
|
<span class="chinese">固钉</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../queue-anim/"
|
|
class="">
|
|
QueueAnim
|
|
<span class="chinese">进出场动画</span>
|
|
</a>
|
|
</li>
|
|
<li class="">
|
|
<a href="../spin/"
|
|
class="">
|
|
Spin
|
|
<span class="chinese">加载中</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</aside>
|
|
|
|
<section class="main-container">
|
|
<article class="markdown">
|
|
<h1>
|
|
Button 按钮
|
|
</h1>
|
|
<p>按钮用于开始一个即时操作。</p>
|
|
<h2 id="何时使用">何时使用<a href="#何时使用" class="anchor">#</a> </h2><p>标记了一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。</p>
|
|
<h2 id="api">API<a href="#api" class="anchor">#</a> </h2><ul>
|
|
<li><p>通过设置 Button 的属性来产生不同的按钮样式,推荐顺序为:<code>type</code> -> <code>shape</code> -> <code>size</code> -> <code>loading</code> -> <code>disabled</code></p>
|
|
</li>
|
|
<li><p>按钮的属性说明如下:</p>
|
|
</li>
|
|
</ul>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>属性</th>
|
|
<th>说明</th>
|
|
<th>类型</th>
|
|
<th>默认值</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>type</td>
|
|
<td>设置按钮类型,可选值为 <code>primary</code> <code>ghost</code> 或者不设</td>
|
|
<td>string</td>
|
|
<td>-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>htmlType</td>
|
|
<td>设置 <code>button</code> 原生的 <code>type</code> 值,可选值请参考 HTML标准</td>
|
|
<td>string</td>
|
|
<td><code>button</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>shape</td>
|
|
<td>设置按钮形状,可选值为 <code>circle</code> <code>circle-outline</code> 或者不设</td>
|
|
<td>string</td>
|
|
<td>无</td>
|
|
</tr>
|
|
<tr>
|
|
<td>size</td>
|
|
<td>设置按钮大小,可选值为 <code>small</code> <code>large</code> 或者不设</td>
|
|
<td>string</td>
|
|
<td><code>default</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>loading</td>
|
|
<td>设置按钮载入状态</td>
|
|
<td>boolean</td>
|
|
<td>false</td>
|
|
</tr>
|
|
<tr>
|
|
<td>onClick</td>
|
|
<td><code>click</code> 事件的 handler</td>
|
|
<td>function</td>
|
|
<td><code>function() {}</code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<ul>
|
|
<li><code><Button>Hello world!</Button></code> 最终会被渲染为 <code><button>Hello world!</button></code>,并且除了上表中的属性,其它属性都会直接传到 <code><button></button></code></li>
|
|
</ul>
|
|
|
|
</article>
|
|
<h2 class="component-demos">
|
|
代码演示
|
|
<i class="anticon anticon-appstore icon-all" title="展开全部代码"></i>
|
|
</h2>
|
|
<div class="code-boxes">
|
|
<div class="code-boxes-col-2-1"><div class="code-box" id="demo-basic">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-basic"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-basic');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"主按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
null,
|
|
"次按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"幽灵按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "dashed" },
|
|
"虚线按钮"
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>主按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span>></span>次按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>幽灵按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"dashed"</span>></span>虚线按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>,
|
|
mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-basic .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-basic">按钮类型</a>
|
|
</div>
|
|
<p>按钮有三种类型:主按钮、次按钮、幽灵按钮。</p>
|
|
<p>通过设置 <code>type</code> 为 <code>primary</code> <code>ghost</code> 可分别创建主按钮、幽灵按钮,若不设置 <code>type</code> 值则为次按钮。不同的样式可以用来区别其重要程度。</p>
|
|
<p>主按钮和次按钮可独立使用,需要强引导用主按钮。幽灵按钮用于和主按钮组合。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div><div class="code-box" id="demo-size">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-size"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-size');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "large" },
|
|
"大号按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"中号按钮(默认)"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "small" },
|
|
"小号按钮"
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>大号按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>中号按钮(默认)<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>小号按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>
|
|
, mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-size .ant-btn {
|
|
margin-right: 8px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-size">按钮尺寸</a>
|
|
</div>
|
|
<p>按钮有大、中、小三种尺寸。</p>
|
|
<p>通过设置 <code>size</code> 为 <code>large</code> <code>small</code> 分别把按钮设为大、小尺寸。若不设置 <code>size</code>,则尺寸为中。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div><div class="code-box" id="demo-loading">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-loading"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-loading');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
var App = React.createClass({
|
|
displayName: "App",
|
|
getInitialState: function getInitialState() {
|
|
return {
|
|
loading: false,
|
|
iconLoading: false
|
|
};
|
|
},
|
|
enterLoading: function enterLoading() {
|
|
this.setState({ loading: true });
|
|
},
|
|
enterIconLoading: function enterIconLoading() {
|
|
this.setState({ iconLoading: true });
|
|
},
|
|
render: function render() {
|
|
return React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "large", loading: true },
|
|
"加载中"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", loading: true },
|
|
"加载中"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "small", loading: true },
|
|
"加载中"
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", loading: this.state.loading, onClick: this.enterLoading },
|
|
"点击变加载"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", loading: this.state.iconLoading, onClick: this.enterIconLoading },
|
|
React.createElement(_antd.Icon, { type: "poweroff" }),
|
|
"点击变加载"
|
|
)
|
|
);
|
|
}
|
|
});
|
|
|
|
ReactDOM.render(React.createElement(App, null), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button, Icon } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
<span class="hljs-keyword">const</span> App = React.createClass({
|
|
getInitialState() {
|
|
<span class="hljs-keyword">return</span> {
|
|
loading: <span class="hljs-literal">false</span>,
|
|
iconLoading: <span class="hljs-literal">false</span>,
|
|
};
|
|
},
|
|
enterLoading() {
|
|
<span class="hljs-keyword">this</span>.setState({ loading: <span class="hljs-literal">true</span> });
|
|
},
|
|
enterIconLoading() {
|
|
<span class="hljs-keyword">this</span>.setState({ iconLoading: <span class="hljs-literal">true</span> });
|
|
},
|
|
render() {
|
|
<span class="hljs-keyword">return</span> (
|
|
<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span> <span class="hljs-attribute">loading</span>></span>
|
|
加载中
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">loading</span>></span>
|
|
加载中
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span> <span class="hljs-attribute">loading</span>></span>
|
|
加载中
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">loading</span>=<span class="hljs-value">{this.state.loading}</span> <span class="hljs-attribute">onClick</span>=<span class="hljs-value">{this.enterLoading}</span>></span>
|
|
点击变加载
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">loading</span>=<span class="hljs-value">{this.state.iconLoading}</span> <span class="hljs-attribute">onClick</span>=<span class="hljs-value">{this.enterIconLoading}</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"poweroff"</span> /></span>点击变加载
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>
|
|
)</span>;
|
|
}
|
|
});
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">App</span> /></span>, mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-loading .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-loading">加载中</a>
|
|
</div>
|
|
<p>添加 <code>loading</code> 属性即可让按钮处于加载状态,最后两个按钮演示点击后进入加载状态。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div><div class="code-box" id="demo-icon">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-icon"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-icon');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle", size: "large" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "large" },
|
|
React.createElement(_antd.Icon, { type: "search" }),
|
|
"大按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
React.createElement(_antd.Icon, { type: "search" }),
|
|
"中按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle", size: "small" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", size: "small" },
|
|
React.createElement(_antd.Icon, { type: "search" }),
|
|
"小按钮"
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline", size: "large" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline", size: "small" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button, Icon } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
大按钮
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
中按钮
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
小按钮
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>,
|
|
mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-icon .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-icon">图标按钮</a>
|
|
</div>
|
|
<p><code>Button</code> 内可以嵌套图标,图标可以放在文字前、后,也可以单独存在。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="code-boxes-col-2-1"><div class="code-box" id="demo-shape">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-shape"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-shape');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle", size: "large" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", shape: "circle", size: "small" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline", size: "large" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", shape: "circle-outline", size: "small" },
|
|
React.createElement(_antd.Icon, { type: "search" })
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button, Icon } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">shape</span>=<span class="hljs-value">"circle-outline"</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"search"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>
|
|
, mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-shape .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-shape">按钮形状</a>
|
|
</div>
|
|
<p>通过设置 <code>shape</code> 为 <code>circle</code> <code>circle-outline</code>,可以把按钮形状设为圆形,并且 <code>circle-outline</code> 在 hover 时会有动画效果。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div><div class="code-box" id="demo-disabled">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-disabled"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-disabled');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"主按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary", disabled: true },
|
|
"主按钮(失效)"
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
null,
|
|
"次按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ disabled: true },
|
|
"次按钮(失效)"
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"幽灵按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost", disabled: true },
|
|
"幽灵按钮(失效)"
|
|
),
|
|
React.createElement("br", null),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "dashed" },
|
|
"虚线按钮"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "dashed", disabled: true },
|
|
"虚线按钮(失效)"
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>主按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span> <span class="hljs-attribute">disabled</span>></span>主按钮(失效)<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span>></span>次按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">disabled</span>></span>次按钮(失效)<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>幽灵按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span> <span class="hljs-attribute">disabled</span>></span>幽灵按钮(失效)<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">br</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"dashed"</span>></span>虚线按钮<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"dashed"</span> <span class="hljs-attribute">disabled</span>></span>虚线按钮(失效)<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>
|
|
, mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-disabled .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-disabled">不可用</a>
|
|
</div>
|
|
<p>添加 <code>disabled</code> 属性即可让按钮处于不可用状态,同时按钮样式也会改变。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div><div class="code-box" id="demo-button-group">
|
|
<div class="code-box-demo">
|
|
<div id="components-button-demo-button-group"></div>
|
|
<script>mountNode = document.getElementById('components-button-demo-button-group');</script>
|
|
<script>(function(){"use strict";
|
|
|
|
var _antd = require("antd");
|
|
|
|
var ButtonGroup = _antd.Button.Group;
|
|
|
|
ReactDOM.render(React.createElement(
|
|
"div",
|
|
null,
|
|
React.createElement(
|
|
"h4",
|
|
null,
|
|
"基本组合"
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"确定"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"取消"
|
|
)
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ disabled: true },
|
|
"左"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ disabled: true },
|
|
"中"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ disabled: true },
|
|
"右"
|
|
)
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"左"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"中"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"中"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
null,
|
|
"右"
|
|
)
|
|
),
|
|
React.createElement(
|
|
"h4",
|
|
null,
|
|
"带图标按钮组合"
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
React.createElement(_antd.Icon, { type: "left" }),
|
|
React.createElement(
|
|
"span",
|
|
null,
|
|
"后退"
|
|
)
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
"前进",
|
|
React.createElement(_antd.Icon, { type: "right" })
|
|
)
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
React.createElement(_antd.Icon, { type: "cloud" })
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "primary" },
|
|
React.createElement(_antd.Icon, { type: "cloud-download" })
|
|
)
|
|
),
|
|
React.createElement(
|
|
"h4",
|
|
null,
|
|
"多个组合"
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"1"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"2"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"3"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"4"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
React.createElement(
|
|
"span",
|
|
null,
|
|
"前进"
|
|
),
|
|
React.createElement(_antd.Icon, { type: "right" })
|
|
)
|
|
),
|
|
React.createElement(
|
|
"h4",
|
|
null,
|
|
"尺寸"
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
{ size: "large" },
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"大"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"大"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"大"
|
|
)
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
null,
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"默认"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"默认"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"默认"
|
|
)
|
|
),
|
|
React.createElement(
|
|
ButtonGroup,
|
|
{ size: "small" },
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"小"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"小"
|
|
),
|
|
React.createElement(
|
|
_antd.Button,
|
|
{ type: "ghost" },
|
|
"小"
|
|
)
|
|
)
|
|
), mountNode);})()</script><div class="highlight"><pre><code class="javascript"><span class="hljs-keyword">import</span> { Button, Icon } <span class="hljs-keyword">from</span> <span class="hljs-string">'antd'</span>;
|
|
<span class="hljs-keyword">const</span> ButtonGroup = Button.Group;
|
|
|
|
ReactDOM.render(<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">h4</span>></span>基本组合<span class="hljs-tag"></<span class="hljs-title">h4</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>确定<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>取消<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">disabled</span>></span>左<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">disabled</span>></span>中<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">disabled</span>></span>右<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>左<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>中<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>中<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span>></span>右<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">h4</span>></span>带图标按钮组合<span class="hljs-tag"></<span class="hljs-title">h4</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"left"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">span</span>></span>后退<span class="hljs-tag"></<span class="hljs-title">span</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>
|
|
前进
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"right"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"cloud"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"primary"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"cloud-download"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">h4</span>></span>多个组合<span class="hljs-tag"></<span class="hljs-title">h4</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>1<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>2<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>3<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>4<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">span</span>></span>前进<span class="hljs-tag"></<span class="hljs-title">span</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Icon</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"right"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-title">h4</span>></span>尺寸<span class="hljs-tag"></<span class="hljs-title">h4</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"large"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>大<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>大<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>大<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>默认<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>默认<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>默认<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">ButtonGroup</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"small"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>小<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>小<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-title">Button</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"ghost"</span>></span>小<span class="hljs-tag"></<span class="hljs-title">Button</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">ButtonGroup</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-title">div</span>></span>
|
|
, mountNode);</span></code></pre></div><style>
|
|
#components-button-demo-button-group h4 {
|
|
margin: 16px 0;
|
|
font-size: 14px;
|
|
line-height: 1;
|
|
font-weight: normal;
|
|
}
|
|
#components-button-demo-button-group h4:first-child {
|
|
margin-top: 0;
|
|
}
|
|
#components-button-demo-button-group .ant-btn {
|
|
margin-bottom: 8px;
|
|
}
|
|
#components-button-demo-button-group .ant-btn-group {
|
|
margin-right: 8px;
|
|
}
|
|
#components-button-demo-button-group .ant-btn {
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
</div>
|
|
<div class="code-box-meta markdown">
|
|
<div class="code-box-title">
|
|
<a href="#demo-button-group">按钮组合</a>
|
|
</div>
|
|
<p>可以将多个 <code>Button</code> 放入 <code>Button.Group</code> 的容器中。</p>
|
|
<p>通过设置 <code>size</code> 为 <code>large</code> <code>small</code> 分别把按钮组合设为大、小尺寸。若不设置 <code>size</code>,则尺寸为中。</p>
|
|
<span class="collapse anticon anticon-circle-o-right" unselectable="none"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<ul class="toc demos-anchor">
|
|
<li>
|
|
<a title="按钮类型" href="#demo-basic">
|
|
<span>按钮类型</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="按钮形状" href="#demo-shape">
|
|
<span>按钮形状</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="按钮尺寸" href="#demo-size">
|
|
<span>按钮尺寸</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="不可用" href="#demo-disabled">
|
|
<span>不可用</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="加载中" href="#demo-loading">
|
|
<span>加载中</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="按钮组合" href="#demo-button-group">
|
|
<span>按钮组合</span>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a title="图标按钮" href="#demo-icon">
|
|
<span>图标按钮</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<div class="api-container markdown"></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/antd-init">脚手架</a>
|
|
<a target="_blank" href="http://ant-tool.github.io/">开发工具</a>
|
|
</li>
|
|
<li>
|
|
<h2>关于我们</h2>
|
|
<a target="_blank" href="https://github.com/ant-ued/blog">博客 - Ant UED</a>
|
|
</li>
|
|
<li>
|
|
<h2>联系我们</h2>
|
|
<a target="_blank" href="https://github.com/ant-design/ant-design/issues">反馈和建议</a>
|
|
<a target="_blank" href="https://gitter.im/ant-design/ant-design">讨论</a>
|
|
<a target="_blank" href="http://dwz.cn/2AF9ao">报告 Bug</a>
|
|
</li>
|
|
<li>
|
|
<div>©2015 蚂蚁金服体验技术部出品</div>
|
|
<div>文档版本:<span id="versions-select"></span></div>
|
|
</li>
|
|
</ul>
|
|
</footer>
|
|
<script data-no-instant>
|
|
if (!location.port) {
|
|
(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');
|
|
InstantClick.on('change', function() {
|
|
ga('send', 'pageview', location.pathname + location.search);
|
|
});
|
|
}
|
|
</script>
|
|
<script data-no-instant>
|
|
InstantClick.on('change', function() {
|
|
InstantClickChangeFns.forEach(function(fn) {
|
|
fn();
|
|
});
|
|
});
|
|
InstantClick.init();
|
|
</script>
|
|
</body>
|
|
</html> |