Ant Design Popconfirm - 将预选按钮更改为取消
Ant Design Popconfirm - Changing the preselected button to Cancel
Ant Design 中的 Popconfirm-modal 在模态-window 打开时预选了确认 ("Yes"-)-按钮。
模态源代码:
import { Popconfirm, message } from 'antd';
function confirm(e) {
console.log(e);
message.success('Click on Yes');
}
function cancel(e) {
console.log(e);
message.error('Click on No');
}
ReactDOM.render(
<Popconfirm title="Are you sure delete this task?" onConfirm={confirm} onCancel={cancel} okText="Yes" cancelText="No">
<a href="#">Delete</a>
</Popconfirm>
, mountNode);
此处的文档和现场演示:Ant Design Documentation
有没有办法改变描述的默认行为?
准确地说:
有没有办法定义取消(分别为"No"-)按钮,当模态框出现时预选?
恐怕只能得到half-way
如果您提供 okType="default"
属性,"Yes" 按钮将不再有 type="primary"
,因此看起来就像 "No" 按钮。
但是不支持相应的 cancelType
属性,这意味着您无法将 "No" 按钮设为蓝色。
这确实感觉有点跛 API,因此您可能会成功提交实施 cancelType
的 PR。应该是针对 https://github.com/ant-design/ant-design/blob/master/components/popconfirm/index.tsx
的非常简单的 3 行补丁
Ant Design 中的 Popconfirm-modal 在模态-window 打开时预选了确认 ("Yes"-)-按钮。
模态源代码:
import { Popconfirm, message } from 'antd';
function confirm(e) {
console.log(e);
message.success('Click on Yes');
}
function cancel(e) {
console.log(e);
message.error('Click on No');
}
ReactDOM.render(
<Popconfirm title="Are you sure delete this task?" onConfirm={confirm} onCancel={cancel} okText="Yes" cancelText="No">
<a href="#">Delete</a>
</Popconfirm>
, mountNode);
此处的文档和现场演示:Ant Design Documentation
有没有办法改变描述的默认行为?
准确地说: 有没有办法定义取消(分别为"No"-)按钮,当模态框出现时预选?
恐怕只能得到half-way
如果您提供 okType="default"
属性,"Yes" 按钮将不再有 type="primary"
,因此看起来就像 "No" 按钮。
但是不支持相应的 cancelType
属性,这意味着您无法将 "No" 按钮设为蓝色。
这确实感觉有点跛 API,因此您可能会成功提交实施 cancelType
的 PR。应该是针对 https://github.com/ant-design/ant-design/blob/master/components/popconfirm/index.tsx