【发布时间】:2020-03-21 09:42:48
【问题描述】:
我正在尝试让自己熟悉 react.js 和 typescript。 我试图声明一个 JSON 数组,但它给了我一个错误,说 ... 不能分配给 JSON
这是我的代码:
import React from 'react';
type MyProps = {
message?: string;
};
type MyState = {
chat_list : Array<JSON>
count: number; // like this
};
class ChatList extends React.Component<MyProps, MyState> {
state: MyState = {
count: 0,
chat_list : [
{
"name":"true",
"active" : true
}
]
};
...
我该如何解决这个问题?
【问题讨论】:
标签: reactjs typescript react-typescript