[英]Type A is not assignable to type B in typescript with antdesign
Hi guys I was writing this code in typescript with using ant design and I got this issue (TS2322).大家好,我正在使用 ant 设计在 typescript 中编写此代码,我遇到了这个问题(TS2322)。 I wanted to use 'Input' from 'Ant Design' and set the first value as null.
我想使用“Ant Design”中的“输入”并将第一个值设置为 null。 After that I was gonna put it in the Input it occurs some errors.
之后我要把它放在输入中,它会发生一些错误。 Does anyone know how to solve this issue?
有谁知道如何解决这个问题? Thank you for your help in advance: *FYI.
提前感谢您的帮助:*仅供参考。 my antd version is 4.21.0 and typescript is 4.7 2
我的 antd 版本是 4.21.0 而 typescript 是 4.7 2
import { Button, Col, Input, Row } from "antd";
import { useRef } from 'react';
import styles from './Signin.module.css';
export default function Signin() {
const emailRef = useRef<typeof Input>(null);
const passwordRef = useRef<typeof Input>(null);
return <Row align="middle" className={styles.signin_row}>
<Col span={24}>
<Row className={styles.signin_contents}>
<Col span={12}>
<img src="/bg_signin.png" alt="Signin" className={styles.signin_bg}/>
</Col>
<Col span={12}>
<div className={styles.signin_title}>My Books</div>
<div className={styles.signin_subtitle}>Please Note Your Opinion</div>
<div className={styles.signin_underline} />
<div className={styles.email_title}>
Email
<span className={styles.required}> *</span>
</div>
<div className={styles.input_area}>
<Input
placeholder="Email"
autoComplete="email"
name="email" className={styles.input}
ref ={emailRef}/>
</div>
<div className={styles.password_title}>
Password
<span className={styles.required}> *</span>
</div>
<div className={styles.input_area}>
<Input
type="password"
autoComplete="current-password"
name="password"
className={styles.input}
ref={passwordRef}/>
</div>
<div className={styles.button_area}>
<Button size="large" className={styles.button}>Sign In</Button>
</div>
</Col>
</Row>
</Col>
</Row>
}
Add: oops I forgot to put what the error message says添加:哎呀我忘了把错误信息说什么
Try:尝试:
import { Button, Col, Input, Row, InputRef } from "antd";
const emailRef = useRef<InputRef | null>(null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.