Button hints using antd framework in vscode

别等时光非礼了梦想. 提交于 2019-12-07 14:44:20

问题


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.


回答1:


Hello I have updated @types/react as 16.8.11 in my package.json. This solved my problem.




回答2:


Downgrade the "@types/react": "^16.8.8" will solve it




回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!