1. 点击按钮删除时的确认弹窗,场景:表格,列表删除时的确认

buttonConfirm.jpg

ButtonConfirm封装

  1. 场景:Table点击删除按钮,弹窗确认
  2. 在antd.Button组件基础上封装, type属性值增加del

/ButtonConfirm.js

  1. import React from 'react'
  2. import PropTypes from 'prop-types'
  3. import { Button, Popconfirm } from 'antd'
  4. const style = { width: 200 }
  5. ButtonConfirm.propTypes = {
  6. onClick: PropTypes.func.isRequired
  7. }
  8. function ButtonConfirm (props) {
  9. const {
  10. onClick,
  11. text='删除',
  12. title='确认删除吗?'
  13. } = props
  14. // if (type !== 'del') return <Button {...props}></Button>
  15. return (
  16. <Popconfirm
  17. title={title}
  18. style={style}
  19. onConfirm={onClick}
  20. >
  21. <Button
  22. type="danger"
  23. {...props}
  24. onClick={e => e.preventDefault()}>{text}</Button>
  25. </Popconfirm>
  26. )
  27. }
  28. export default ButtonConfirm

/index.js

  1. export { default as ButtonConfirm } from './BtnConfirm.js'

ButtonConfirm使用

  1. 表格删除时的确认 ```jsx [ { title: “操作”, key: ‘action’, width: 120, render: (text, record) => renderAction(record), } ]

function renderAction (record) { const attr = { onClick: onCopy, title: ‘确认复制!’, text: ‘复制’, type: ‘primary’, size: ‘small’ } return ( <> onDelete(record.id)} /> </> ) }

  1. <a name="8KHnt"></a>
  2. ## button选中组件
  3. ```jsx
  4. position: absolute;
  5. right: 0;
  6. bottom: 0;
  7. color: rgb(255, 255, 255);
  8. position: absolute;
  9. right: 0px;
  10. bottom: 2px;
  11. <Button>
  12. 明天
  13. <span style={style}>
  14. <span className="triangle" style={{ position: 'absolute', right: 0, bottom: 0}}></span>
  15. <Icon type="check" style={{color: '#fff',position: 'absolute', right: 0, bottom: 2}}/>
  16. </span>
  17. </Button>

image.png

button勾选

image.png
按钮三角形 https://ice.work/playground/new