我在 vscode 中使用 antd 的按钮和输入。但它在按钮上显示错误,我想知道为什么。
我试过输入法,没有显示错误。如图所示。
import React from 'react';
import styles from './index.css';
import router from 'umi/router';
import {Input, Button} from 'antd';
export default function() {
const handleClick=()=>{
router.push('/homepage/');
}
return (
<div className={styles.normal}>
<div className={styles.welcome} />
<h1 className={styles.title}>login</h1>
<ul className={styles.list}>
<li><label>username:</label><Input className={styles.input} placeholder="username"/></li>
<li><label>password:</label><Input className={styles.input} placeholder="password"/></li>
<li>
<Button type="primary" shape="round" onClick={handleClick}>login</Button>
</li>
</ul>
</div>
);
}
实际输出显示:
<--language:lang-none-->
"message": "Type '{ children: string; type: \"primary\"; shape: \"round\"; onClick: () => void; }' is missing the following properties from type 'Pick<Pick<(Readonly<AnchorButtonProps> & Readonly<{ children?: ReactNode; }>) | (Readonly<NativeButtonProps> & Readonly<{ children?: ReactNode; }>), \"defaultChecked\" | \"defaultValue\" | ... 257 more ... | \"block\"> & Pick<...> & Pick<...>, \"defaultChecked\" | ... 256 more ... | \"shape\">': defaultChecked, defaultValue, suppressContentEditableWarning, suppressHydrationWarning, and 250 more."
另外,我想问一下如何使用静态资源?示例项目只是使用css背景url方式来显示图片。
您好,我已在 package.json 中将 @types/react 更新为 16.8.11。这解决了我的问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)