React confim popup components 弹出确认框组件的实现

本文展示了如何在React中创建一个确认弹出框组件,包括组件的结构、Stylus CSS样式和实际应用场景。提供了最终效果的预览,并鼓励读者通过提供的GitHub链接探索更多React组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先来张效果图:


1.Components

// components

import React from 'react';
import { Link } from 'react-router';

class ConfirmWins extends React.Component {
  constructor() {
    super();
  }

  render() {
    const props = this.props;
    return (
      <div className="confirm-wins-container">
        <div className="wins">
          <div className="title text-center">{props.title}</div>
          <div className="desc gray-text96">{props.desc}</div>
          <div className="fn-btn text-center">
            {props.leftBtn?<span className="btn left-btn" onClick={props.onLeftClick}>{props.leftBtn.text}</span>:''}
            <span className="btn right-btn" onClick={props.onRightClick}>{props.rightBtn.text}</span>
          </div>
        </div>
      </div>
    );
  }
}

ConfirmWins.propTypes = {
  title: React.PropTypes.string.isRequired,
  desc: React.PropTypes.string.isRequired,
  leftBtn: React.PropTypes.object,
  rightBtn: React.PropTypes.object.isRequired,
  onLeftClick: React.PropTypes.func,
  onRightClick: React.PropTypes.func.isRequired,
};

export default ConfirmWins;

 

 

2. Stylus css

@import '../util/constant'

.confirm-wins-container
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);

  .wins
    position: absolute;
    margin-top: 50%;
    background: $bgColor;
    width: 80%;
    margin-left: 10%;
    padding: 1em;
    border-radius 4px

    .title
      font-size: 16px;
      margin: .5em;

    .fn-btn
      margin-top 1em

      .btn
        display: inline-block;
        border: 1px solid $brandMainColor;
        height: 3em;
        width: 8em;
        line-height: 3em;
        border-radius 4px

      .left-btn
        float: left;
        color $brandMainColor

      .right-btn
        float: right;
        border: 1px solid $brandMainColor;
        background $brandMainColor
        color #fff

 

3.应用

const addressConfirm = {
      title: '很抱歉',
      desc: '您还没有设置收货地址,请设置您的收货地址',
      leftBtn: {
        text: '确认'
      },
      rightBtn: {
        text: '设置地址'
      }
    };


{state.isShowAddressPopUp?<ConfirmWins {...addressConfirm} onLeftClick={this.closePopUp.bind(this, 'isShowAddressPopUp')} onRightClick={this.goLink.bind(this, '#/address/add')} />:''}

 

 

写在最后,关于更多React Components请访问:

https://github.com/qiaolevip/react-mobile

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值