1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
presuffix.md 1.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
HughHzWu Отправлено 6 лет назад 267b8e7
order title
8
zh-CN en-US
前缀和后缀
prefix and suffix

zh-CN

在输入框上添加前缀或后缀图标。

en-US

Add prefix or suffix icons inside input.

import { Input, Icon } from 'choerodon-ui';

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      userName: 'xxx',
    };
  }

  emitEmpty = () => {
    this.userNameInput.focus();
    this.setState({ userName: '' });
  }

  onChangeUserName = (e) => {
    this.setState({ userName: e.target.value });
  }

  render() {
    const { userName } = this.state;
    const suffix = userName ? <Icon type="close" onClick={this.emitEmpty} /> : null;
    return (
      <Input
        placeholder="Enter your username"
        prefix="input-"
        suffix={suffix}
        label="username"
        value={userName}
        onChange={this.onChangeUserName}
        ref={node => this.userNameInput = node}
        copy
      />
    );
  }
}

ReactDOM.render(<App />, mountNode);
.icon-close {
  cursor: pointer;
  color: #ccc;
  transition: color 0.3s;
  font-size: 12px;
}
.icon-close:hover {
  color: #999;
}
.icon-close:active {
  color: #666;
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/open-hand-choerodon-ui.git
git@gitlife.ru:oschina-mirror/open-hand-choerodon-ui.git
oschina-mirror
open-hand-choerodon-ui
open-hand-choerodon-ui
master