0.2.0 • Published 3 years ago

@busyzz/react-popup v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

线上预览

https://busyzz-1994.github.io/react-popup/

npm.io

开始

yarn add @busyzz/react-popup --save
#or
npm install @busyzz/react-popup --save

使用案例

import ReactPopup, { PopupProps } from '@busyzz/react-popup';
const App = () => {
  const [v, setV] = React.useState(false);
  const [position, setPosition] = React.useState<PopupProps['position']>(
    'center'
  );
  const onClick = (p: PopupProps['position']) => {
    setPosition(p);
    setV(true);
  };
  return (
    <div>
      <ReactPopup onClose={() => setV(false)} visible={v} position={position}>
        <h1>test</h1>
      </ReactPopup>
      <div>
        <button onClick={() => onClick('center')}>center</button>
      </div>
      <div>
        <button onClick={() => onClick('left')}>left</button>
      </div>
      <div>
        <button onClick={() => onClick('right')}>right</button>
      </div>
      <div>
        <button onClick={() => onClick('top')}>top</button>
      </div>
      <div>
        <button onClick={() => onClick('bottom')}>bottom</button>
      </div>
    </div>
  );
};

属性

属性说明类型默认值
visible显示/隐藏booleanfalse
position内容出现的位置'center'/'top'/'left'/'bottom'/'right'center
mask是否显示遮罩booleantrue
maskClosable点击遮罩自动关闭booleantrue
onClose关闭的回调Function()=>void
wrapClassName添加到最外层容器的 classstring-
destroyOnClose关闭动画结束后是否删除节点booleanfalse