mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
Fix onClick in dropdown button, close #1097
This commit is contained in:
parent
67305505c2
commit
0edd5ada9a
@ -10,22 +10,24 @@
|
||||
import { Menu, Dropdown } from 'antd';
|
||||
const DropdownButton = Dropdown.Button;
|
||||
|
||||
function handleButtonClick() {
|
||||
console.log('click button');
|
||||
}
|
||||
|
||||
function handleMenuClick(e) {
|
||||
console.log('click', e);
|
||||
}
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu.Item>
|
||||
<a target="_blank" href="http://www.alipay.com/">第一个菜单项</a>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<a target="_blank" href="http://www.taobao.com/">第二个菜单项</a>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<a target="_blank" href="http://www.tmall.com/">第三个菜单项</a>
|
||||
</Menu.Item>
|
||||
<Menu onClick={handleMenuClick}>
|
||||
<Menu.Item key="1">第一个菜单项</Menu.Item>
|
||||
<Menu.Item key="2">第二个菜单项</Menu.Item>
|
||||
<Menu.Item key="3">第三个菜单项</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
|
||||
ReactDOM.render(
|
||||
<DropdownButton overlay={menu} type="primary">
|
||||
<DropdownButton onClick={handleButtonClick} overlay={menu} type="primary">
|
||||
某功能按钮
|
||||
</DropdownButton>
|
||||
, mountNode);
|
||||
|
@ -3,32 +3,34 @@ import Button from '../button';
|
||||
import Icon from '../icon';
|
||||
import Dropdown from './dropdown';
|
||||
const ButtonGroup = Button.Group;
|
||||
|
||||
const align = {
|
||||
points: ['tr', 'br'],
|
||||
overlay: {
|
||||
adjustX: 1,
|
||||
adjustY: 1,
|
||||
},
|
||||
offset: [0, 4],
|
||||
targetOffset: [0, 0],
|
||||
};
|
||||
import classNames from 'classnames';
|
||||
|
||||
export default React.createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
align,
|
||||
align: {
|
||||
points: ['tr', 'br'],
|
||||
overlay: {
|
||||
adjustX: 1,
|
||||
adjustY: 1,
|
||||
},
|
||||
offset: [0, 4],
|
||||
targetOffset: [0, 0],
|
||||
},
|
||||
type: 'default',
|
||||
};
|
||||
},
|
||||
render() {
|
||||
const { type, overlay, trigger, align, children, className, ...restProps } = this.props;
|
||||
const cls = classNames({
|
||||
'ant-dropdown-button': true,
|
||||
className: !!className,
|
||||
});
|
||||
return (
|
||||
<ButtonGroup className="ant-dropdown-button">
|
||||
<Button type={this.props.type}>
|
||||
{this.props.children}
|
||||
</Button>
|
||||
<Dropdown {...this.props}>
|
||||
<Button type={this.props.type}>
|
||||
<ButtonGroup {...restProps} className={cls}>
|
||||
<Button type={type}>{children}</Button>
|
||||
<Dropdown align={align} overlay={overlay} trigger={trigger}>
|
||||
<Button type={type}>
|
||||
<Icon type="down" />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
|
Loading…
Reference in New Issue
Block a user