好酷屋

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

好酷屋

发布于2022-12-23
标签:更多>

好酷屋教程网小编为您收集和整理了DevExtreme初级入门教程(React篇):TypeScript支持的相关教程:DevExtremeReact组件提供了TypeScript声明,Strict类型允许您在早期阶段捕获错误并使用代码完成和自动重构等功能。以下代码展示了将TypeScript与DevExtreme组

DevExtreme React组件提供了TypeScript声明,Strict类型允许您在早期阶段捕获错误并使用代码完成和自动重构等功能。

以下代码展示了将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 (

{this.props.data.text} was clicked {this.state.counter} times

以上就是好酷屋教程网小编为您收集和整理的DevExtreme初级入门教程(React篇):TypeScript支持相关内容,如果对您有帮助,请帮忙分享这篇文章^_^

本文来源: https://www.haoku5.com/IT/63a56cf8e53c284ecf026669.html

相关推荐

    热门专题