2018-11-29 10:03:16 +08:00
|
|
|
---
|
|
|
|
order: 10
|
|
|
|
title:
|
2019-05-07 14:57:32 +08:00
|
|
|
zh-CN: 密码框
|
|
|
|
en-US: Password box
|
2018-11-29 10:03:16 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
密码框。
|
2018-11-29 10:03:16 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
Input type of password.
|
2018-11-29 10:03:16 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2020-04-30 21:19:16 +08:00
|
|
|
import { EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
2022-10-31 21:15:59 +08:00
|
|
|
import { Button, Input, Space } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2018-12-02 17:28:24 +08:00
|
|
|
|
2022-10-31 21:15:59 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [passwordVisible, setPasswordVisible] = React.useState(false);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Space direction="vertical">
|
|
|
|
<Input.Password placeholder="input password" />
|
|
|
|
<Input.Password
|
|
|
|
placeholder="input password"
|
|
|
|
iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
|
|
|
|
/>
|
|
|
|
<Space direction="horizontal">
|
|
|
|
<Input.Password
|
|
|
|
placeholder="input password"
|
|
|
|
visibilityToggle={{ visible: passwordVisible, onVisibleChange: setPasswordVisible }}
|
|
|
|
/>
|
|
|
|
<Button style={{ width: 80 }} onClick={() => setPasswordVisible(prevState => !prevState)}>
|
|
|
|
{passwordVisible ? 'Hide' : 'Show'}
|
|
|
|
</Button>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
};
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|