index.jsx 1016 Bytes
Newer Older
1 2 3 4 5
import React, { useState, useEffect } from 'react';
import { Radio } from 'antd';
import styles from './index.less';

const RadioBox = props => {
6
  const { radioTitle, radioOptions, currentVal, currentIndex, callBack } = props;
7 8 9 10 11 12 13 14 15
  useEffect(() => {}, []);
  // 选择时通过回调函数传回要改变数据的索引跟选中的值
  const onChange = e => {
    callBack(currentIndex, e.target.value);
  };
  return (
    <div className={styles.radioBox}>
      <div className={styles.radioTitle}>{radioTitle}:</div>
      <div className={styles.radioContent}>
16
        <Radio.Group value={currentVal}>
17
          {radioOptions.map((item, num) => (
18 19 20 21 22 23 24
            <Radio
              disabled={item.disabled}
              value={item.version}
              key={num}
              className={styles.radio}
              onClick={onChange}
            >
25 26 27 28 29 30 31 32 33 34
              {item.functionName + item.version}
            </Radio>
          ))}
        </Radio.Group>
      </div>
    </div>
  );
};

export default RadioBox;