reactjs - vscode中使用antd框架的按钮提示
问题描述
我在 vscode 中使用 antd 的 Button 和 Input。但它在 Button 上显示错误,我想知道原因。
我试过输入,它没有显示错误。如图所示。
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。这解决了我的问题。
推荐阅读
- android - FLUTTER:任务':app:compileFlutterBuildDebug'执行失败无法创建父目录
- c++ - 声明与 void 不兼容
- c++ - 函数调用的参数太多,预期单个参数“nums”,有 3 个参数
- windows-installer - 对 BizTalk 生成的 MSI 文件进行产品版本控制
- c# - localhost websocket (wss://localhost:xyz/) 并非对所有用户都可用
- python - 如何在 Jupyter Notebook 中导入特定版本的 numpy?
- java - 我的数组没有到达数组的最后一个元素
- react-native - React Native Linking 抛出错误:无法打开 URL:
- java - 文本上方的 JMenu 图标
- javascript - 地图函数内的数组似乎接收数据,地图外它是空的