1.0.3 • Published 5 years ago

react-dialog-yzy v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Install

npm i react-dialog-yzy

or

yarn react-dialog-yzy

Usage

  import Dialog from 'react-dialog';

  yesFn = () => {
    this.setState({
      isShow: false
    })
  }
  noFn = () => {
    this.setState({
      isShow: false
    })
  }
  openDialog = () => {
    this.setState({
      isShow: true
    })
  }

  render() {
    const { isShow, title, text, YesTitle, NoTitle} = this.state
    return (
      <div className="App">
        <button style={{
          width: '120px', 
          height: '60px', 
          background: 'yellowgreen', 
          color: '#fff', 
          fontSize: '20px', 
          borderRadius: '8px', 
          marginTop: '100px',
          outline: 'none',
          border: '1px solid transparent',
          cursor: 'pointer'
        }} 
        onClick={this.openDialog}>click</button>
        <Dialog 
        className='dialogStyle'
        isShow={isShow}
        title={title}
        text={text}
        YesTitle={YesTitle}
        NoTitle={NoTitle}
        yesBtn={this.yesFn}
        noBtn={this.noFn}
        />
      </div>
    );
  }

Props

nametypedefaultdescription
classNameStringnullneed add '!important'
isShowBooleanfalsecontrol dialog display
titleString'这是一个标题'Title Name
textString'这是弹窗内容'Text Name
noBtnFunctionnullcontrol dialog noBtn function (if not have prop noBtn will no 'noBtn' button)
yesBtnFunctionnullcontrol dialog yesBtn function (if not have prop yesBtn will no 'yesBtn' button)
YesTitleStringYesyesBtn name
NoTitleStringNonoBtn name