【发布时间】:2018-08-07 16:14:42
【问题描述】:
antd 教程在 typescript 中的使用
- 创建反应应用...好的
- yarn add antd ...ok
- 在App.css中导入antd.css ...ok
但是我遇到了这个错误信息
D:/8VSCode/vcjoo-ant/src/App.tsx
(16,10): Type '{ shape: "circle"; icon: string; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes<Button> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<AnchorButtonProps> & Pick<InferProps<{ type: any; shape: any; size: any; htmlType: any; ... 4 more ...; block: any; }>, "htmlType">, "color" | ... 258 more ... | "htmlType"> & Partial<...> & Partial<...>) | ...'.
Type '{ shape: "circle"; icon: string; }' is not assignable to type 'Pick<Readonly<{ children?: ReactNode; }> & Readonly<NativeButtonProps> & Pick<InferProps<{ type: any; shape: any; size: any; htmlType: any; onClick: any; loading: any; className: any; icon: any; block: any; }>, "htmlType">, "color" | ... 262 more ... | "value">'.
Property 'htmlType' is missing in type '{ shape: "circle"; icon: string; }'.
我可以在 antd 中使用 to {InputNumber} 组件 但是,我不能 {Button} 组件,因为有一些这个错误
我的错误是什么?
App.tsx
import { InputNumber, Button } from 'antd';
import * as React from 'react';
import './App.css';
import logo from './logo.svg';
class App extends React.Component {
public render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<InputNumber min={1} max={10} defaultValue={3} />
<Button shape="circle" icon="search" />
<p className="App">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
</div>
);
}
}
export default App;
App.css
@import '~antd/dist/antd.css';
.App {
text-align: center;
}
...
【问题讨论】:
-
我在 组件中添加了 args,例如“ 所以,我可以使用到 组件!!但是..我遇到了另一个错误 [ ts] 类型 ...
标签: reactjs typescript antd