I'm using Button and Input of antd in vscode. But It shows error on Button and I want to know why.
I have tried Input, and it shows no error. Which is showed in the picture.
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>
);
}
The actual output shows:
<--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."
plus, I want to ask how to use static resource? The sample project just use the css background url way to show pictures.
Hello I have updated @types/react as 16.8.11 in my package.json. This solved my problem.
Downgrade the "@types/react": "^16.8.8" will solve it
This issue was fixed by antd 3 days ago. Just update your antd to version 3.16.3 and you will be fine.
Execute: npm i antd@3.16.3 --save
or yarn antd@3.16.3
If you want more details, you can find in this issue
来源:https://stackoverflow.com/questions/55606270/button-hints-using-antd-framework-in-vscode