PhoneView.js 775 Bytes
Newer Older
陈帅's avatar
陈帅 committed
1 2
import React, { Fragment, PureComponent } from 'react';
import { Input } from 'antd';
3
import styles from './PhoneView.less';
陈帅's avatar
陈帅 committed
4 5 6 7 8 9 10 11 12 13 14

class PhoneView extends PureComponent {
  render() {
    const { value, onChange } = this.props;
    let values = ['', ''];
    if (value) {
      values = value.split('-');
    }
    return (
      <Fragment>
        <Input
15
          className={styles.area_code}
陈帅's avatar
陈帅 committed
16
          value={values[0]}
jim's avatar
jim committed
17
          onChange={e => {
陈帅's avatar
陈帅 committed
18 19 20 21
            onChange(`${e.target.value}-${values[1]}`);
          }}
        />
        <Input
22
          className={styles.phone_number}
jim's avatar
jim committed
23
          onChange={e => {
陈帅's avatar
陈帅 committed
24 25 26 27 28 29 30 31 32 33
            onChange(`${values[0]}-${e.target.value}`);
          }}
          value={values[1]}
        />
      </Fragment>
    );
  }
}

export default PhoneView;