index.jsx 1.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import React, { useState, useEffect } from 'react';
import { Radio } from 'antd';
import styles from './index.less';

const RadioBox = props => {
  const {
    radioTitle,
    radioOptions,
    currentVal,
    currentIndex,
    callBack,
  } = props;
  useEffect(() => {}, []);
  // 选择时通过回调函数传回要改变数据的索引跟选中的值
  const onChange = e => {
    callBack(currentIndex, e.target.value);
  };
  return (
    <div className={styles.radioBox}>
      <div className={styles.radioTitle}>{radioTitle}:</div>
      <div className={styles.radioContent}>
22
        <Radio.Group value={currentVal}>
23
          {radioOptions.map((item, num) => (
24 25 26 27 28 29 30
            <Radio
              disabled={item.disabled}
              value={item.version}
              key={num}
              className={styles.radio}
              onClick={onChange}
            >
31 32 33 34 35 36 37 38 39 40
              {item.functionName + item.version}
            </Radio>
          ))}
        </Radio.Group>
      </div>
    </div>
  );
};

export default RadioBox;