DevExtreme初级入门教程(React篇):TypeScript支持

以下代码展示了将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初级入门教程(React篇):TypeScript支持

DevExtreme | 下载试用


DevExpress技术交流群5:742234706      欢迎一起进群讨论

DevExpress年终放大招!省钱攻略提前奉上,更适合中国区用户!
标签:

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

上一篇 2021年11月5日
下一篇 2021年11月5日

相关推荐

发表回复

登录后才能评论