以下代码展示了将TypeScript与DevExtreme组件结合使用的示例:
App.tsx
import React from 'react';import List from 'devextreme-react/list';import 'devextreme/dist/css/dx.light.css';interface IListItemProps {text: string;}interface IComponentState {counter: number;}const items: IListItemProps[] = [{ text: "Item 1" },{ text: "Item 2" },{ text: "Item 3" }];class Item extends React.Component<IListItemProps, IComponentState> {constructor(props: IListItemProps) {super(props);this.state = {counter: 0};this.addCounter = this.addCounter.bind(this);}public render() {return (<div onClick={this.addCounter}>{this.props.data.text} was clicked {this.state.counter} times</div>);}private addCounter() {this.setState({counter: this.state.counter + 1});}}class App extends React.Component {render() {return (<List items={items} itemComponent={Item} />);}}export default App;
支持的版本

DevExtreme | 下载试用
DevExpress技术交流群5:742234706 欢迎一起进群讨论

标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!